diff --git a/sdk/servicebus/azure-mgmt-servicebus/_meta.json b/sdk/servicebus/azure-mgmt-servicebus/_meta.json index ec8e866ec7dc..1bd639e3161e 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/_meta.json +++ b/sdk/servicebus/azure-mgmt-servicebus/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.4.5", + "autorest": "3.7.2", "use": [ - "@autorest/python@5.8.4", - "@autorest/modelerfour@4.19.2" + "@autorest/python@5.13.0", + "@autorest/modelerfour@4.19.3" ], - "commit": "1ebd7cba28910bc3d01fbc625f81e6a6e9a2756f", + "commit": "8e9c6de91b0a4a8d702baa652dc4244614d96105", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/servicebus/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.8.4 --use=@autorest/modelerfour@4.19.2 --version=3.4.5", + "autorest_command": "autorest specification/servicebus/resource-manager/readme.md --multiapi --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.13.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/servicebus/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/_configuration.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/_configuration.py index 9531d7678c12..a5b79adab717 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/_configuration.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/_configuration.py @@ -12,7 +12,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -68,4 +68,4 @@ def _configure( 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) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/_service_bus_management_client.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/_service_bus_management_client.py index ca0015ffe734..b7d8e21d6dce 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/_service_bus_management_client.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/_service_bus_management_client.py @@ -11,10 +11,11 @@ from typing import TYPE_CHECKING +from msrest import Deserializer, Serializer + from azure.mgmt.core import ARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin -from msrest import Deserializer, Serializer from ._configuration import ServiceBusManagementClientConfiguration @@ -23,7 +24,6 @@ from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse class _SDKClient(object): def __init__(self, *args, **kwargs): @@ -70,12 +70,10 @@ def __init__( credential, # type: "TokenCredential" subscription_id, # type: str api_version=None, # type: Optional[str] - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str profile=KnownProfiles.default, # type: KnownProfiles **kwargs # type: Any ): - if not base_url: - base_url = 'https://management.azure.com' self._config = ServiceBusManagementClientConfiguration(credential, subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(ServiceBusManagementClient, self).__init__( diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/_configuration.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/_configuration.py index 81b406d86751..d5711226f3eb 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/_configuration.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/_configuration.py @@ -12,7 +12,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -64,4 +64,4 @@ def _configure( 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) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/_service_bus_management_client.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/_service_bus_management_client.py index 5cea8a1a549a..6eeb2436d413 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/_service_bus_management_client.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/_service_bus_management_client.py @@ -11,16 +11,17 @@ from typing import Any, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from msrest import Deserializer, Serializer + from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin -from msrest import Deserializer, Serializer from ._configuration import ServiceBusManagementClientConfiguration if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential class _SDKClient(object): @@ -68,12 +69,10 @@ def __init__( credential: "AsyncTokenCredential", subscription_id: str, api_version: Optional[str] = None, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", profile: KnownProfiles = KnownProfiles.default, **kwargs # type: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' self._config = ServiceBusManagementClientConfiguration(credential, subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(ServiceBusManagementClient, self).__init__( diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/__init__.py deleted file mode 100644 index 629acc6e01a4..000000000000 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/__init__.py +++ /dev/null @@ -1,37 +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 ._namespaces_operations import NamespacesOperations -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations -from ._private_link_resources_operations import PrivateLinkResourcesOperations -from ._operations import Operations -from ._disaster_recovery_configs_operations import DisasterRecoveryConfigsOperations -from ._queues_operations import QueuesOperations -from ._topics_operations import TopicsOperations -from ._event_hubs_operations import EventHubsOperations -from ._migration_configs_operations import MigrationConfigsOperations -from ._premium_messaging_regions_operations import PremiumMessagingRegionsOperations -from ._regions_operations import RegionsOperations -from ._subscriptions_operations import SubscriptionsOperations -from ._rules_operations import RulesOperations - -__all__ = [ - 'NamespacesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'Operations', - 'DisasterRecoveryConfigsOperations', - 'QueuesOperations', - 'TopicsOperations', - 'EventHubsOperations', - 'MigrationConfigsOperations', - 'PremiumMessagingRegionsOperations', - 'RegionsOperations', - 'SubscriptionsOperations', - 'RulesOperations', -] diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/_disaster_recovery_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/_disaster_recovery_configs_operations.py deleted file mode 100644 index a2cc7a31350d..000000000000 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/_disaster_recovery_configs_operations.py +++ /dev/null @@ -1,725 +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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class DisasterRecoveryConfigsOperations: - """DisasterRecoveryConfigsOperations 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.mgmt.servicebus.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 check_name_availability( - self, - resource_group_name: str, - namespace_name: str, - parameters: "_models.CheckNameAvailability", - **kwargs - ) -> "_models.CheckNameAvailabilityResult": - """Check the give namespace name availability. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param parameters: Parameters to check availability of the given namespace name. - :type parameters: ~azure.mgmt.servicebus.models.CheckNameAvailability - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CheckNameAvailability') - body_content_kwargs['content'] = body_content - request = self._client.post(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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability'} # type: ignore - - def list( - self, - resource_group_name: str, - namespace_name: str, - **kwargs - ) -> AsyncIterable["_models.ArmDisasterRecoveryListResult"]: - """Gets all Alias(Disaster Recovery configurations). - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ArmDisasterRecoveryListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.models.ArmDisasterRecoveryListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ArmDisasterRecoveryListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('ArmDisasterRecoveryListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs'} # type: ignore - - async def create_or_update( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - parameters: "_models.ArmDisasterRecovery", - **kwargs - ) -> Optional["_models.ArmDisasterRecovery"]: - """Creates or updates a new Alias(Disaster Recovery configuration). - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param alias: The Disaster Recovery configuration name. - :type alias: str - :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). - :type parameters: ~azure.mgmt.servicebus.models.ArmDisasterRecovery - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArmDisasterRecovery, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.models.ArmDisasterRecovery or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ArmDisasterRecovery"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ArmDisasterRecovery') - 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.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}'} # type: ignore - - async def delete( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs - ) -> None: - """Deletes an Alias(Disaster Recovery configuration). - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param alias: The Disaster Recovery configuration name. - :type alias: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - 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.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}'} # type: ignore - - async def get( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs - ) -> "_models.ArmDisasterRecovery": - """Retrieves Alias(Disaster Recovery configuration) for primary or secondary namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param alias: The Disaster Recovery configuration name. - :type alias: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArmDisasterRecovery, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.models.ArmDisasterRecovery - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ArmDisasterRecovery"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - 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.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}'} # type: ignore - - async def break_pairing( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs - ) -> None: - """This operation disables the Disaster Recovery and stops replicating changes from primary to - secondary namespaces. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param alias: The Disaster Recovery configuration name. - :type alias: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.break_pairing.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(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.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - break_pairing.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing'} # type: ignore - - async def fail_over( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - parameters: Optional["_models.FailoverProperties"] = None, - **kwargs - ) -> None: - """Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param alias: The Disaster Recovery configuration name. - :type alias: str - :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). - :type parameters: ~azure.mgmt.servicebus.models.FailoverProperties - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.fail_over.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if parameters is not None: - body_content = self._serialize.body(parameters, 'FailoverProperties') - else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - fail_over.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover'} # type: ignore - - def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs - ) -> AsyncIterable["_models.SBAuthorizationRuleListResult"]: - """Gets the authorization rules for a namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param alias: The Disaster Recovery configuration name. - :type alias: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRuleListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('SBAuthorizationRuleListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules'} # type: ignore - - async def get_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs - ) -> "_models.SBAuthorizationRule": - """Gets an authorization rule for a namespace by rule name. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param alias: The Disaster Recovery configuration name. - :type alias: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - 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.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}'} # type: ignore - - async def list_keys( - self, - resource_group_name: str, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs - ) -> "_models.AccessKeys": - """Gets the primary and secondary connection strings for the namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param alias: The Disaster Recovery configuration name. - :type alias: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessKeys"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(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.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('AccessKeys', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys'} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/_event_hubs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/_event_hubs_operations.py deleted file mode 100644 index 418ffb0a3e08..000000000000 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/_event_hubs_operations.py +++ /dev/null @@ -1,117 +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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class EventHubsOperations: - """EventHubsOperations 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.mgmt.servicebus.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 - - def list_by_namespace( - self, - resource_group_name: str, - namespace_name: str, - **kwargs - ) -> AsyncIterable["_models.EventHubListResult"]: - """Gets all the Event Hubs in a service bus Namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.models.EventHubListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_namespace.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('EventHubListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list_by_namespace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/eventhubs'} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/_migration_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/_migration_configs_operations.py deleted file mode 100644 index 1c94451c1a5b..000000000000 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/_migration_configs_operations.py +++ /dev/null @@ -1,499 +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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class MigrationConfigsOperations: - """MigrationConfigsOperations 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.mgmt.servicebus.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 - - def list( - self, - resource_group_name: str, - namespace_name: str, - **kwargs - ) -> AsyncIterable["_models.MigrationConfigListResult"]: - """Gets all migrationConfigurations. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MigrationConfigListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.models.MigrationConfigListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MigrationConfigListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('MigrationConfigListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations'} # type: ignore - - async def _create_and_start_migration_initial( - self, - resource_group_name: str, - namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: "_models.MigrationConfigProperties", - **kwargs - ) -> Optional["_models.MigrationConfigProperties"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.MigrationConfigProperties"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_and_start_migration_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'MigrationConfigProperties') - 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.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - _create_and_start_migration_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}'} # type: ignore - - async def begin_create_and_start_migration( - self, - resource_group_name: str, - namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: "_models.MigrationConfigProperties", - **kwargs - ) -> AsyncLROPoller["_models.MigrationConfigProperties"]: - """Creates Migration configuration and starts migration of entities from Standard to Premium - namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". - :type config_name: str or ~azure.mgmt.servicebus.models.MigrationConfigurationName - :param parameters: Parameters required to create Migration Configuration. - :type parameters: ~azure.mgmt.servicebus.models.MigrationConfigProperties - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either MigrationConfigProperties or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.models.MigrationConfigProperties] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MigrationConfigProperties"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._create_and_start_migration_initial( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - config_name=config_name, - parameters=parameters, - cls=lambda x,y,z: x, - **kwargs - ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_and_start_migration.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}'} # type: ignore - - async def delete( - self, - resource_group_name: str, - namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], - **kwargs - ) -> None: - """Deletes a MigrationConfiguration. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". - :type config_name: str or ~azure.mgmt.servicebus.models.MigrationConfigurationName - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - 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, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}'} # type: ignore - - async def get( - self, - resource_group_name: str, - namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], - **kwargs - ) -> "_models.MigrationConfigProperties": - """Retrieves Migration Config. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". - :type config_name: str or ~azure.mgmt.servicebus.models.MigrationConfigurationName - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MigrationConfigProperties, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.models.MigrationConfigProperties - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MigrationConfigProperties"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - 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.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}'} # type: ignore - - async def complete_migration( - self, - resource_group_name: str, - namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], - **kwargs - ) -> None: - """This operation Completes Migration of entities by pointing the connection strings to Premium - namespace and any entities created after the operation will be under Premium Namespace. - CompleteMigration operation will fail when entity migration is in-progress. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". - :type config_name: str or ~azure.mgmt.servicebus.models.MigrationConfigurationName - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.complete_migration.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(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.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - complete_migration.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade'} # type: ignore - - async def revert( - self, - resource_group_name: str, - namespace_name: str, - config_name: Union[str, "_models.MigrationConfigurationName"], - **kwargs - ) -> None: - """This operation reverts Migration. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". - :type config_name: str or ~azure.mgmt.servicebus.models.MigrationConfigurationName - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.revert.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(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.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - revert.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert'} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/_namespaces_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/_namespaces_operations.py deleted file mode 100644 index a63a612d1633..000000000000 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/_namespaces_operations.py +++ /dev/null @@ -1,1745 +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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class NamespacesOperations: - """NamespacesOperations 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.mgmt.servicebus.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 - - def list_ip_filter_rules( - self, - resource_group_name: str, - namespace_name: str, - **kwargs - ) -> AsyncIterable["_models.IpFilterRuleListResult"]: - """Gets a list of IP Filter rules for a Namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IpFilterRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.models.IpFilterRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IpFilterRuleListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_ip_filter_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('IpFilterRuleListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list_ip_filter_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules'} # type: ignore - - async def create_or_update_ip_filter_rule( - self, - resource_group_name: str, - namespace_name: str, - ip_filter_rule_name: str, - parameters: "_models.IpFilterRule", - **kwargs - ) -> "_models.IpFilterRule": - """Creates or updates an IpFilterRule for a Namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param ip_filter_rule_name: The IP Filter Rule name. - :type ip_filter_rule_name: str - :param parameters: The Namespace IpFilterRule. - :type parameters: ~azure.mgmt.servicebus.models.IpFilterRule - :keyword callable cls: A custom type or function that will be passed the direct response - :return: IpFilterRule, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.models.IpFilterRule - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IpFilterRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_ip_filter_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'ipFilterRuleName': self._serialize.url("ip_filter_rule_name", ip_filter_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'IpFilterRule') - 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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('IpFilterRule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - create_or_update_ip_filter_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules/{ipFilterRuleName}'} # type: ignore - - async def delete_ip_filter_rule( - self, - resource_group_name: str, - namespace_name: str, - ip_filter_rule_name: str, - **kwargs - ) -> None: - """Deletes an IpFilterRule for a Namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param ip_filter_rule_name: The IP Filter Rule name. - :type ip_filter_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_ip_filter_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'ipFilterRuleName': self._serialize.url("ip_filter_rule_name", ip_filter_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - 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, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete_ip_filter_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules/{ipFilterRuleName}'} # type: ignore - - async def get_ip_filter_rule( - self, - resource_group_name: str, - namespace_name: str, - ip_filter_rule_name: str, - **kwargs - ) -> "_models.IpFilterRule": - """Gets an IpFilterRule for a Namespace by rule name. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param ip_filter_rule_name: The IP Filter Rule name. - :type ip_filter_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: IpFilterRule, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.models.IpFilterRule - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IpFilterRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_ip_filter_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'ipFilterRuleName': self._serialize.url("ip_filter_rule_name", ip_filter_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - 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.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('IpFilterRule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_ip_filter_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules/{ipFilterRuleName}'} # type: ignore - - def list( - self, - **kwargs - ) -> AsyncIterable["_models.SBNamespaceListResult"]: - """Gets all the available namespaces within the subscription, irrespective of the resource groups. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBNamespaceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.models.SBNamespaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SBNamespaceListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('SBNamespaceListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces'} # type: ignore - - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.SBNamespaceListResult"]: - """Gets the available namespaces within a resource group. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBNamespaceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.models.SBNamespaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SBNamespaceListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('SBNamespaceListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces'} # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - namespace_name: str, - parameters: "_models.SBNamespace", - **kwargs - ) -> Optional["_models.SBNamespace"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.SBNamespace"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBNamespace') - 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, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore - - async def begin_create_or_update( - self, - resource_group_name: str, - namespace_name: str, - parameters: "_models.SBNamespace", - **kwargs - ) -> AsyncLROPoller["_models.SBNamespace"]: - """Creates or updates a service namespace. Once created, this namespace's resource manifest is - immutable. This operation is idempotent. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param parameters: Parameters supplied to create a namespace resource. - :type parameters: ~azure.mgmt.servicebus.models.SBNamespace - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either SBNamespace or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.models.SBNamespace] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SBNamespace"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - parameters=parameters, - cls=lambda x,y,z: x, - **kwargs - ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize('SBNamespace', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore - - async def _delete_initial( - self, - resource_group_name: str, - namespace_name: str, - **kwargs - ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - 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, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore - - async def begin_delete( - self, - resource_group_name: str, - namespace_name: str, - **kwargs - ) -> AsyncLROPoller[None]: - """Deletes an existing namespace. This operation also removes all associated resources under the - namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - cls=lambda x,y,z: x, - **kwargs - ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore - - async def get( - self, - resource_group_name: str, - namespace_name: str, - **kwargs - ) -> "_models.SBNamespace": - """Gets a description for the specified namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBNamespace, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.models.SBNamespace - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SBNamespace"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - 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.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBNamespace', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore - - async def update( - self, - resource_group_name: str, - namespace_name: str, - parameters: "_models.SBNamespaceUpdateParameters", - **kwargs - ) -> Optional["_models.SBNamespace"]: - """Updates a service namespace. Once created, this namespace's resource manifest is immutable. - This operation is idempotent. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param parameters: Parameters supplied to update a namespace resource. - :type parameters: ~azure.mgmt.servicebus.models.SBNamespaceUpdateParameters - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBNamespace, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.models.SBNamespace or None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.SBNamespace"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(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, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore - - async def create_or_update_network_rule_set( - self, - resource_group_name: str, - namespace_name: str, - parameters: "_models.NetworkRuleSet", - **kwargs - ) -> "_models.NetworkRuleSet": - """Gets NetworkRuleSet for a Namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param parameters: The Namespace NetworkRuleSet. - :type parameters: ~azure.mgmt.servicebus.models.NetworkRuleSet - :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkRuleSet, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkRuleSet"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_network_rule_set.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'NetworkRuleSet') - 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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - create_or_update_network_rule_set.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkrulesets/default'} # type: ignore - - async def get_network_rule_set( - self, - resource_group_name: str, - namespace_name: str, - **kwargs - ) -> "_models.NetworkRuleSet": - """Gets NetworkRuleSet for a Namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkRuleSet, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkRuleSet"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_network_rule_set.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - 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.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_network_rule_set.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkrulesets/default'} # type: ignore - - def list_virtual_network_rules( - self, - resource_group_name: str, - namespace_name: str, - **kwargs - ) -> AsyncIterable["_models.VirtualNetworkRuleListResult"]: - """Gets a list of VirtualNetwork rules for a Namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VirtualNetworkRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.models.VirtualNetworkRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetworkRuleListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_virtual_network_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('VirtualNetworkRuleListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list_virtual_network_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules'} # type: ignore - - async def create_or_update_virtual_network_rule( - self, - resource_group_name: str, - namespace_name: str, - virtual_network_rule_name: str, - parameters: "_models.VirtualNetworkRule", - **kwargs - ) -> "_models.VirtualNetworkRule": - """Creates or updates an VirtualNetworkRule for a Namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param virtual_network_rule_name: The Virtual Network Rule name. - :type virtual_network_rule_name: str - :param parameters: The Namespace VirtualNetworkRule. - :type parameters: ~azure.mgmt.servicebus.models.VirtualNetworkRule - :keyword callable cls: A custom type or function that will be passed the direct response - :return: VirtualNetworkRule, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.models.VirtualNetworkRule - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetworkRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_virtual_network_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'virtualNetworkRuleName': self._serialize.url("virtual_network_rule_name", virtual_network_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'VirtualNetworkRule') - 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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('VirtualNetworkRule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - create_or_update_virtual_network_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules/{virtualNetworkRuleName}'} # type: ignore - - async def delete_virtual_network_rule( - self, - resource_group_name: str, - namespace_name: str, - virtual_network_rule_name: str, - **kwargs - ) -> None: - """Deletes an VirtualNetworkRule for a Namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param virtual_network_rule_name: The Virtual Network Rule name. - :type virtual_network_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_virtual_network_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'virtualNetworkRuleName': self._serialize.url("virtual_network_rule_name", virtual_network_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - 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, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete_virtual_network_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules/{virtualNetworkRuleName}'} # type: ignore - - async def get_virtual_network_rule( - self, - resource_group_name: str, - namespace_name: str, - virtual_network_rule_name: str, - **kwargs - ) -> "_models.VirtualNetworkRule": - """Gets an VirtualNetworkRule for a Namespace by rule name. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param virtual_network_rule_name: The Virtual Network Rule name. - :type virtual_network_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: VirtualNetworkRule, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.models.VirtualNetworkRule - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetworkRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_virtual_network_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'virtualNetworkRuleName': self._serialize.url("virtual_network_rule_name", virtual_network_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - 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.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('VirtualNetworkRule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_virtual_network_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules/{virtualNetworkRuleName}'} # type: ignore - - def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - **kwargs - ) -> AsyncIterable["_models.SBAuthorizationRuleListResult"]: - """Gets the authorization rules for a namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRuleListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('SBAuthorizationRuleListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules'} # type: ignore - - async def create_or_update_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - parameters: "_models.SBAuthorizationRule", - **kwargs - ) -> "_models.SBAuthorizationRule": - """Creates or updates an authorization rule for a namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :param parameters: The shared access authorization rule. - :type parameters: ~azure.mgmt.servicebus.models.SBAuthorizationRule - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBAuthorizationRule') - 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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - create_or_update_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}'} # type: ignore - - async def delete_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs - ) -> None: - """Deletes a namespace authorization rule. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.delete_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - 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, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}'} # type: ignore - - async def get_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs - ) -> "_models.SBAuthorizationRule": - """Gets an authorization rule for a namespace by rule name. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - 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.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}'} # type: ignore - - async def list_keys( - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs - ) -> "_models.AccessKeys": - """Gets the primary and secondary connection strings for the namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessKeys"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(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.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('AccessKeys', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys'} # type: ignore - - async def regenerate_keys( - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - parameters: "_models.RegenerateAccessKeyParameters", - **kwargs - ) -> "_models.AccessKeys": - """Regenerates the primary or secondary connection strings for the namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. - :type parameters: ~azure.mgmt.servicebus.models.RegenerateAccessKeyParameters - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessKeys"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('AccessKeys', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - regenerate_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys'} # type: ignore - - async def check_name_availability( - self, - parameters: "_models.CheckNameAvailability", - **kwargs - ) -> "_models.CheckNameAvailabilityResult": - """Check the give namespace name availability. - - :param parameters: Parameters to check availability of the given namespace name. - :type parameters: ~azure.mgmt.servicebus.models.CheckNameAvailability - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CheckNameAvailability') - body_content_kwargs['content'] = body_content - request = self._client.post(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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability'} # type: ignore - - async def migrate( - self, - resource_group_name: str, - namespace_name: str, - parameters: "_models.SBNamespaceMigrate", - **kwargs - ) -> None: - """This operation Migrate the given namespace to provided name type. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param parameters: Parameters supplied to migrate namespace type. - :type parameters: ~azure.mgmt.servicebus.models.SBNamespaceMigrate - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.migrate.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBNamespaceMigrate') - body_content_kwargs['content'] = body_content - request = self._client.post(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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - migrate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrate'} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/_operations.py deleted file mode 100644 index 4115b2948fbe..000000000000 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/_operations.py +++ /dev/null @@ -1,105 +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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class Operations: - """Operations 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.mgmt.servicebus.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 - - def list( - self, - **kwargs - ) -> AsyncIterable["_models.OperationListResult"]: - """Lists all of the available ServiceBus REST API operations. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.ServiceBus/operations'} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/_premium_messaging_regions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/_premium_messaging_regions_operations.py deleted file mode 100644 index 805efa7f6557..000000000000 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/_premium_messaging_regions_operations.py +++ /dev/null @@ -1,109 +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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class PremiumMessagingRegionsOperations: - """PremiumMessagingRegionsOperations 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.mgmt.servicebus.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 - - def list( - self, - **kwargs - ) -> AsyncIterable["_models.PremiumMessagingRegionsListResult"]: - """Gets the available premium messaging regions for servicebus. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PremiumMessagingRegionsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.models.PremiumMessagingRegionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PremiumMessagingRegionsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('PremiumMessagingRegionsListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/premiumMessagingRegions'} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/_private_endpoint_connections_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/_private_endpoint_connections_operations.py deleted file mode 100644 index 940d34827306..000000000000 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,374 +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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class PrivateEndpointConnectionsOperations: - """PrivateEndpointConnectionsOperations 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.mgmt.servicebus.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 - - def list( - self, - resource_group_name: str, - namespace_name: str, - **kwargs - ) -> AsyncIterable["_models.PrivateEndpointConnectionListResult"]: - """Gets the available PrivateEndpointConnections within a namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('PrivateEndpointConnectionListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections'} # type: ignore - - async def create_or_update( - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - parameters: "_models.PrivateEndpointConnection", - **kwargs - ) -> "_models.PrivateEndpointConnection": - """Creates or updates PrivateEndpointConnections of service namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. - :type private_endpoint_connection_name: str - :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to - namespace resource. - :type parameters: ~azure.mgmt.servicebus.models.PrivateEndpointConnection - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PrivateEndpointConnection') - 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.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - - async def _delete_initial( - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs - ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - 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, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - - async def begin_delete( - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs - ) -> AsyncLROPoller[None]: - """Deletes an existing Private Endpoint Connection. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. - :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - private_endpoint_connection_name=private_endpoint_connection_name, - cls=lambda x,y,z: x, - **kwargs - ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - - async def get( - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs - ) -> "_models.PrivateEndpointConnection": - """Gets a description for the specified Private Endpoint Connection. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. - :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - 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.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/_private_link_resources_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/_private_link_resources_operations.py deleted file mode 100644 index 7635368b8a82..000000000000 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/_private_link_resources_operations.py +++ /dev/null @@ -1,100 +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 ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class PrivateLinkResourcesOperations: - """PrivateLinkResourcesOperations 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.mgmt.servicebus.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, - resource_group_name: str, - namespace_name: str, - **kwargs - ) -> "_models.PrivateLinkResourcesListResult": - """Gets lists of resources that supports Privatelinks. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResourcesListResult, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.models.PrivateLinkResourcesListResult - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourcesListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - 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.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('PrivateLinkResourcesListResult', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources'} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/_queues_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/_queues_operations.py deleted file mode 100644 index b4ae58248234..000000000000 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/_queues_operations.py +++ /dev/null @@ -1,750 +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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class QueuesOperations: - """QueuesOperations 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.mgmt.servicebus.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 - - def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs - ) -> AsyncIterable["_models.SBAuthorizationRuleListResult"]: - """Gets all authorization rules for a queue. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param queue_name: The queue name. - :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRuleListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('SBAuthorizationRuleListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules'} # type: ignore - - async def create_or_update_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - authorization_rule_name: str, - parameters: "_models.SBAuthorizationRule", - **kwargs - ) -> "_models.SBAuthorizationRule": - """Creates an authorization rule for a queue. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param queue_name: The queue name. - :type queue_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :param parameters: The shared access authorization rule. - :type parameters: ~azure.mgmt.servicebus.models.SBAuthorizationRule - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBAuthorizationRule') - 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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - create_or_update_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}'} # type: ignore - - async def delete_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - authorization_rule_name: str, - **kwargs - ) -> None: - """Deletes a queue authorization rule. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param queue_name: The queue name. - :type queue_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.delete_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - 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, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}'} # type: ignore - - async def get_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - authorization_rule_name: str, - **kwargs - ) -> "_models.SBAuthorizationRule": - """Gets an authorization rule for a queue by rule name. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param queue_name: The queue name. - :type queue_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - 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.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}'} # type: ignore - - async def list_keys( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - authorization_rule_name: str, - **kwargs - ) -> "_models.AccessKeys": - """Primary and secondary connection strings to the queue. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param queue_name: The queue name. - :type queue_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessKeys"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(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.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('AccessKeys', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys'} # type: ignore - - async def regenerate_keys( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - authorization_rule_name: str, - parameters: "_models.RegenerateAccessKeyParameters", - **kwargs - ) -> "_models.AccessKeys": - """Regenerates the primary or secondary connection strings to the queue. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param queue_name: The queue name. - :type queue_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. - :type parameters: ~azure.mgmt.servicebus.models.RegenerateAccessKeyParameters - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessKeys"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('AccessKeys', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - regenerate_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys'} # type: ignore - - def list_by_namespace( - self, - resource_group_name: str, - namespace_name: str, - skip: Optional[int] = None, - top: Optional[int] = None, - **kwargs - ) -> AsyncIterable["_models.SBQueueListResult"]: - """Gets the queues within a namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param skip: Skip is only used if a previous operation returned a partial result. If a previous - response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. - :type skip: int - :param top: May be used to limit the number of results to the most recent N usageDetails. - :type top: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBQueueListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.models.SBQueueListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SBQueueListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_namespace.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', maximum=1000, minimum=0) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('SBQueueListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list_by_namespace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues'} # type: ignore - - async def create_or_update( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - parameters: "_models.SBQueue", - **kwargs - ) -> "_models.SBQueue": - """Creates or updates a Service Bus queue. This operation is idempotent. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param queue_name: The queue name. - :type queue_name: str - :param parameters: Parameters supplied to create or update a queue resource. - :type parameters: ~azure.mgmt.servicebus.models.SBQueue - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBQueue, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SBQueue"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBQueue') - 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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBQueue', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}'} # type: ignore - - async def delete( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs - ) -> None: - """Deletes a queue from the specified namespace in a resource group. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param queue_name: The queue name. - :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - 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, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}'} # type: ignore - - async def get( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs - ) -> "_models.SBQueue": - """Returns a description for the specified queue. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param queue_name: The queue name. - :type queue_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBQueue, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SBQueue"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - 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.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBQueue', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}'} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/_regions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/_regions_operations.py deleted file mode 100644 index 4fa9ee2fc6fe..000000000000 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/_regions_operations.py +++ /dev/null @@ -1,113 +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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class RegionsOperations: - """RegionsOperations 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.mgmt.servicebus.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 - - def list_by_sku( - self, - sku: str, - **kwargs - ) -> AsyncIterable["_models.PremiumMessagingRegionsListResult"]: - """Gets the available Regions for a given sku. - - :param sku: The sku type. - :type sku: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PremiumMessagingRegionsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.models.PremiumMessagingRegionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PremiumMessagingRegionsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_sku.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'sku': self._serialize.url("sku", sku, 'str', max_length=50, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('PremiumMessagingRegionsListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list_by_sku.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/sku/{sku}/regions'} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/_rules_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/_rules_operations.py deleted file mode 100644 index 2b268421af09..000000000000 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/_rules_operations.py +++ /dev/null @@ -1,355 +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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class RulesOperations: - """RulesOperations 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.mgmt.servicebus.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 - - def list_by_subscriptions( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - skip: Optional[int] = None, - top: Optional[int] = None, - **kwargs - ) -> AsyncIterable["_models.RuleListResult"]: - """List all the rules within given topic-subscription. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param subscription_name: The subscription name. - :type subscription_name: str - :param skip: Skip is only used if a previous operation returned a partial result. If a previous - response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. - :type skip: int - :param top: May be used to limit the number of results to the most recent N usageDetails. - :type top: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.models.RuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RuleListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_subscriptions.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', maximum=1000, minimum=0) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('RuleListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscriptions.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules'} # type: ignore - - async def create_or_update( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - rule_name: str, - parameters: "_models.Rule", - **kwargs - ) -> "_models.Rule": - """Creates a new rule and updates an existing rule. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param subscription_name: The subscription name. - :type subscription_name: str - :param rule_name: The rule name. - :type rule_name: str - :param parameters: Parameters supplied to create a rule. - :type parameters: ~azure.mgmt.servicebus.models.Rule - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Rule, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Rule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Rule') - 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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Rule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}'} # type: ignore - - async def delete( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - rule_name: str, - **kwargs - ) -> None: - """Deletes an existing rule. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param subscription_name: The subscription name. - :type subscription_name: str - :param rule_name: The rule name. - :type rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - 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, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}'} # type: ignore - - async def get( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - rule_name: str, - **kwargs - ) -> "_models.Rule": - """Retrieves the description for the specified rule. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param subscription_name: The subscription name. - :type subscription_name: str - :param rule_name: The rule name. - :type rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Rule, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Rule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - 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.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Rule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}'} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/_subscriptions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/_subscriptions_operations.py deleted file mode 100644 index d5e8b4750cf5..000000000000 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/_subscriptions_operations.py +++ /dev/null @@ -1,339 +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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class SubscriptionsOperations: - """SubscriptionsOperations 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.mgmt.servicebus.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 - - def list_by_topic( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - skip: Optional[int] = None, - top: Optional[int] = None, - **kwargs - ) -> AsyncIterable["_models.SBSubscriptionListResult"]: - """List all the subscriptions under a specified topic. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param skip: Skip is only used if a previous operation returned a partial result. If a previous - response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. - :type skip: int - :param top: May be used to limit the number of results to the most recent N usageDetails. - :type top: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBSubscriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.models.SBSubscriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SBSubscriptionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_topic.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', maximum=1000, minimum=0) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('SBSubscriptionListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list_by_topic.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions'} # type: ignore - - async def create_or_update( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - parameters: "_models.SBSubscription", - **kwargs - ) -> "_models.SBSubscription": - """Creates a topic subscription. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param subscription_name: The subscription name. - :type subscription_name: str - :param parameters: Parameters supplied to create a subscription resource. - :type parameters: ~azure.mgmt.servicebus.models.SBSubscription - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBSubscription, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SBSubscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBSubscription') - 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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBSubscription', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}'} # type: ignore - - async def delete( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs - ) -> None: - """Deletes a subscription from the specified topic. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param subscription_name: The subscription name. - :type subscription_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - 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, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}'} # type: ignore - - async def get( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs - ) -> "_models.SBSubscription": - """Returns a subscription description for the specified topic. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param subscription_name: The subscription name. - :type subscription_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBSubscription, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SBSubscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - 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.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBSubscription', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}'} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/_topics_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/_topics_operations.py deleted file mode 100644 index 938aad89f58c..000000000000 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/aio/operations/_topics_operations.py +++ /dev/null @@ -1,750 +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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class TopicsOperations: - """TopicsOperations 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.mgmt.servicebus.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 - - def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs - ) -> AsyncIterable["_models.SBAuthorizationRuleListResult"]: - """Gets authorization rules for a topic. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRuleListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('SBAuthorizationRuleListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules'} # type: ignore - - async def create_or_update_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - authorization_rule_name: str, - parameters: "_models.SBAuthorizationRule", - **kwargs - ) -> "_models.SBAuthorizationRule": - """Creates an authorization rule for the specified topic. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :param parameters: The shared access authorization rule. - :type parameters: ~azure.mgmt.servicebus.models.SBAuthorizationRule - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBAuthorizationRule') - 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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - create_or_update_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}'} # type: ignore - - async def get_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - authorization_rule_name: str, - **kwargs - ) -> "_models.SBAuthorizationRule": - """Returns the specified authorization rule. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - 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.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}'} # type: ignore - - async def delete_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - authorization_rule_name: str, - **kwargs - ) -> None: - """Deletes a topic authorization rule. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.delete_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - 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, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}'} # type: ignore - - async def list_keys( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - authorization_rule_name: str, - **kwargs - ) -> "_models.AccessKeys": - """Gets the primary and secondary connection strings for the topic. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessKeys"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(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.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('AccessKeys', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys'} # type: ignore - - async def regenerate_keys( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - authorization_rule_name: str, - parameters: "_models.RegenerateAccessKeyParameters", - **kwargs - ) -> "_models.AccessKeys": - """Regenerates primary or secondary connection strings for the topic. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. - :type parameters: ~azure.mgmt.servicebus.models.RegenerateAccessKeyParameters - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessKeys"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('AccessKeys', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - regenerate_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys'} # type: ignore - - def list_by_namespace( - self, - resource_group_name: str, - namespace_name: str, - skip: Optional[int] = None, - top: Optional[int] = None, - **kwargs - ) -> AsyncIterable["_models.SBTopicListResult"]: - """Gets all the topics in a namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param skip: Skip is only used if a previous operation returned a partial result. If a previous - response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. - :type skip: int - :param top: May be used to limit the number of results to the most recent N usageDetails. - :type top: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBTopicListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.models.SBTopicListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SBTopicListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_namespace.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', maximum=1000, minimum=0) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('SBTopicListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list_by_namespace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics'} # type: ignore - - async def create_or_update( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - parameters: "_models.SBTopic", - **kwargs - ) -> "_models.SBTopic": - """Creates a topic in the specified namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :param parameters: Parameters supplied to create a topic resource. - :type parameters: ~azure.mgmt.servicebus.models.SBTopic - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBTopic, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SBTopic"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBTopic') - 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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBTopic', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}'} # type: ignore - - async def delete( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs - ) -> None: - """Deletes a topic from the specified namespace and resource group. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - 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, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}'} # type: ignore - - async def get( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs - ) -> "_models.SBTopic": - """Returns a description for the specified topic. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param topic_name: The topic name. - :type topic_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBTopic, or the result of cls(response) - :rtype: ~azure.mgmt.servicebus.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SBTopic"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - 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.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('SBTopic', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}'} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/__init__.py index e6ef471ff03a..aa0384448e69 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ServiceBusManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_configuration.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_configuration.py index 70075bad5482..ad9251b95ca2 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_configuration.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_configuration.py @@ -6,22 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -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 @@ -29,26 +27,31 @@ class ServiceBusManagementClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2015-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2015-08-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-servicebus/{}'.format(VERSION)) self._configure(**kwargs) @@ -68,4 +71,4 @@ def _configure( 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) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_metadata.json b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_metadata.json index f0e50cee8bd2..fa76a032b89e 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_metadata.json +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_metadata.json @@ -5,13 +5,13 @@ "name": "ServiceBusManagementClient", "filename": "_service_bus_management_client", "description": "Azure Service Bus client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_service_bus_management_client.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_service_bus_management_client.py index 8e48132a1173..baee73d4e3c6 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_service_bus_management_client.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_service_bus_management_client.py @@ -6,28 +6,23 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient -from ._configuration import ServiceBusManagementClientConfiguration -from .operations import Operations -from .operations import NamespacesOperations -from .operations import QueuesOperations -from .operations import TopicsOperations -from .operations import SubscriptionsOperations from . import models +from ._configuration import ServiceBusManagementClientConfiguration +from .operations import NamespacesOperations, Operations, QueuesOperations, SubscriptionsOperations, TopicsOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class ServiceBusManagementClient(object): +class ServiceBusManagementClient: """Azure Service Bus client. :ivar operations: Operations operations @@ -42,58 +37,64 @@ class ServiceBusManagementClient(object): :vartype subscriptions: azure.mgmt.servicebus.v2015_08_01.operations.SubscriptionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2015-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ServiceBusManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ServiceBusManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.namespaces = NamespacesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queues = QueuesOperations(self._client, self._config, self._serialize, self._deserialize) + self.topics = TopicsOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.namespaces = NamespacesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.queues = QueuesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.topics = TopicsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_vendor.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# 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 azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_version.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_version.py index e7ffc58c0429..e5754a47ce68 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_version.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "7.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/__init__.py index 9016cbc21795..1b5398b4946f 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._service_bus_management_client import ServiceBusManagementClient __all__ = ['ServiceBusManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/_configuration.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/_configuration.py index 36d9b7a35cc5..ac7564916ab6 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/_configuration.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -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 @@ -27,8 +27,12 @@ class ServiceBusManagementClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2015-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -37,15 +41,17 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2015-08-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-servicebus/{}'.format(VERSION)) self._configure(**kwargs) @@ -64,4 +70,4 @@ def _configure( 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) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/_service_bus_management_client.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/_service_bus_management_client.py index b2bce21706fc..56ef267eb9f9 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/_service_bus_management_client.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/_service_bus_management_client.py @@ -6,26 +6,23 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient -from ._configuration import ServiceBusManagementClientConfiguration -from .operations import Operations -from .operations import NamespacesOperations -from .operations import QueuesOperations -from .operations import TopicsOperations -from .operations import SubscriptionsOperations from .. import models +from ._configuration import ServiceBusManagementClientConfiguration +from .operations import NamespacesOperations, Operations, QueuesOperations, SubscriptionsOperations, TopicsOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class ServiceBusManagementClient(object): +class ServiceBusManagementClient: """Azure Service Bus client. :ivar operations: Operations operations @@ -37,59 +34,68 @@ class ServiceBusManagementClient(object): :ivar topics: TopicsOperations operations :vartype topics: azure.mgmt.servicebus.v2015_08_01.aio.operations.TopicsOperations :ivar subscriptions: SubscriptionsOperations operations - :vartype subscriptions: azure.mgmt.servicebus.v2015_08_01.aio.operations.SubscriptionsOperations + :vartype subscriptions: + azure.mgmt.servicebus.v2015_08_01.aio.operations.SubscriptionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2015-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = ServiceBusManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ServiceBusManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.namespaces = NamespacesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queues = QueuesOperations(self._client, self._config, self._serialize, self._deserialize) + self.topics = TopicsOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.namespaces = NamespacesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.queues = QueuesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.topics = TopicsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_namespaces_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_namespaces_operations.py index 2b18ed327fa7..e1a350540ce5 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_namespaces_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_namespaces_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,19 +6,22 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._namespaces_operations import build_check_name_availability_request, build_create_or_update_authorization_rule_request, build_create_or_update_request_initial, build_delete_authorization_rule_request, build_delete_request_initial, build_get_authorization_rule_request, build_get_request, build_list_authorization_rules_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_list_keys_request, build_regenerate_keys_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +47,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def check_name_availability( self, parameters: "_models.CheckNameAvailability", @@ -62,31 +67,27 @@ async def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CheckNameAvailability') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'CheckNameAvailability') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -99,8 +100,11 @@ async def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability"} # type: ignore + + + @distributed_trace def list_by_subscription( self, **kwargs: Any @@ -109,42 +113,42 @@ def list_by_subscription( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either NamespaceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.NamespaceListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.NamespaceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.NamespaceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('NamespaceListResult', pipeline_response) + deserialized = self._deserialize("NamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -153,7 +157,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -162,11 +170,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces'} # type: ignore + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces"} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -178,43 +188,44 @@ def list_by_resource_group( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either NamespaceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.NamespaceListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.NamespaceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.NamespaceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('NamespaceListResult', pipeline_response) + deserialized = self._deserialize("NamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -223,7 +234,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -232,10 +247,11 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces"} # type: ignore async def _create_or_update_initial( self, @@ -249,33 +265,29 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'NamespaceCreateOrUpdateParameters') - 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) + + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'NamespaceCreateOrUpdateParameters') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -293,8 +305,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -313,14 +328,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceCreateOrUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either NamespaceResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2015_08_01.models.NamespaceResource] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either NamespaceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2015_08_01.models.NamespaceResource] + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.NamespaceResource"] lro_delay = kwargs.pop( @@ -333,27 +354,22 @@ async def begin_create_or_update( resource_group_name=resource_group_name, namespace_name=namespace_name, parameters=parameters, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('NamespaceResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -363,11 +379,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - async def _delete_initial( + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -378,26 +394,25 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2015-08-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -407,9 +422,11 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + - async def begin_delete( + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -424,14 +441,17 @@ async def begin_delete( :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-08-01") # type: str polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( @@ -443,24 +463,18 @@ async def begin_delete( raw_result = await self._delete_initial( resource_group_name=resource_group_name, namespace_name=namespace_name, + api_version=api_version, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -470,10 +484,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -496,28 +511,25 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2015-08-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -530,8 +542,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -558,33 +573,29 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'NamespaceUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'NamespaceUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -602,8 +613,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + + @distributed_trace def list_authorization_rules( self, resource_group_name: str, @@ -617,45 +631,48 @@ def list_authorization_rules( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleListResult] + :return: An iterator like instance of either SharedAccessAuthorizationRuleListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessAuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SharedAccessAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SharedAccessAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -664,7 +681,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -673,11 +694,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules"} # type: ignore + @distributed_trace_async async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -695,7 +718,8 @@ async def create_or_update_authorization_rule( :param authorization_rule_name: The authorization rule name. :type authorization_rule_name: str :param parameters: The shared access authorization rule. - :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters + :type parameters: + ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: SharedAccessAuthorizationRuleResource, or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource @@ -706,34 +730,30 @@ async def create_or_update_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SharedAccessAuthorizationRuleCreateOrUpdateParameters') - 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) + + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SharedAccessAuthorizationRuleCreateOrUpdateParameters') + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -746,9 +766,12 @@ async def create_or_update_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}'} # type: ignore - async def delete_authorization_rule( + create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace_async + async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -773,27 +796,26 @@ async def delete_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - - # Construct URL - url = self.delete_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2015-08-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -803,8 +825,10 @@ async def delete_authorization_rule( if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}'} # type: ignore + delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore + + @distributed_trace_async async def get_authorization_rule( self, resource_group_name: str, @@ -830,29 +854,26 @@ async def get_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2015-08-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -865,8 +886,11 @@ async def get_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}'} # type: ignore + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace_async async def list_keys( self, resource_group_name: str, @@ -892,29 +916,26 @@ async def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2015-08-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -927,8 +948,11 @@ async def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore + + + @distributed_trace_async async def regenerate_keys( self, resource_group_name: str, @@ -957,34 +981,30 @@ async def regenerate_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegenerateKeysParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RegenerateKeysParameters') + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -997,4 +1017,6 @@ async def regenerate_keys( return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys'} # type: ignore + + regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_operations.py index 41f1aa1219ff..8534acd433c0 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,19 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,38 +53,40 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -89,7 +95,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -98,7 +108,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.ServiceBus/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.ServiceBus/operations"} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_queues_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_queues_operations.py index 21e4945daaa7..54b276863de4 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_queues_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_queues_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._queues_operations import build_create_or_update_authorization_rule_request, build_create_or_update_request, build_delete_authorization_rule_request, build_delete_request, build_get_authorization_rule_request, build_get_request, build_list_all_request, build_list_authorization_rules_request, build_list_keys_request, build_post_authorization_rule_request, build_regenerate_keys_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_all( self, resource_group_name: str, @@ -55,44 +60,46 @@ def list_all( :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either QueueListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.QueueListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.QueueListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.QueueListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_all.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_all_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_all.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_all_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('QueueListResult', pipeline_response) + deserialized = self._deserialize("QueueListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -101,7 +108,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,11 +121,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_all.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues'} # type: ignore + list_all.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues"} # type: ignore + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -143,34 +156,30 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'QueueCreateOrUpdateParameters') - 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) + + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'QueueCreateOrUpdateParameters') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -183,9 +192,12 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}'} # type: ignore - async def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -210,27 +222,26 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2015-08-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -240,8 +251,10 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -267,29 +280,26 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2015-08-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -302,8 +312,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore + + + @distributed_trace def list_authorization_rules( self, resource_group_name: str, @@ -320,46 +333,50 @@ def list_authorization_rules( :param queue_name: The queue name. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleListResult] + :return: An iterator like instance of either SharedAccessAuthorizationRuleListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessAuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SharedAccessAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SharedAccessAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -368,7 +385,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -377,11 +398,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules"} # type: ignore + @distributed_trace_async async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -402,7 +425,8 @@ async def create_or_update_authorization_rule( :param authorization_rule_name: The authorization rule name. :type authorization_rule_name: str :param parameters: The shared access authorization rule. - :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters + :type parameters: + ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: SharedAccessAuthorizationRuleResource, or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource @@ -413,35 +437,31 @@ async def create_or_update_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SharedAccessAuthorizationRuleCreateOrUpdateParameters') - 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) + + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SharedAccessAuthorizationRuleCreateOrUpdateParameters') + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -454,8 +474,11 @@ async def create_or_update_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}'} # type: ignore + create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace_async async def post_authorization_rule( self, resource_group_name: str, @@ -484,30 +507,27 @@ async def post_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - - # Construct URL - url = self.post_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + + request = build_post_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.post_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -520,9 +540,12 @@ async def post_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - post_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}'} # type: ignore - async def delete_authorization_rule( + post_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace_async + async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -550,28 +573,27 @@ async def delete_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - - # Construct URL - url = self.delete_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -581,8 +603,10 @@ async def delete_authorization_rule( if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}'} # type: ignore + delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + @distributed_trace_async async def get_authorization_rule( self, resource_group_name: str, @@ -611,30 +635,27 @@ async def get_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -647,8 +668,11 @@ async def get_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}'} # type: ignore + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace_async async def list_keys( self, resource_group_name: str, @@ -677,30 +701,27 @@ async def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -713,8 +734,11 @@ async def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore + + + @distributed_trace_async async def regenerate_keys( self, resource_group_name: str, @@ -746,35 +770,31 @@ async def regenerate_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegenerateKeysParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RegenerateKeysParameters') + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -787,4 +807,6 @@ async def regenerate_keys( return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys'} # type: ignore + + regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_subscriptions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_subscriptions_operations.py index ecad0389db18..1a224f61abbb 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_subscriptions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_subscriptions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._subscriptions_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_all_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_all( self, resource_group_name: str, @@ -57,46 +62,50 @@ def list_all( :param topic_name: The topic name. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionListResult] + :return: An iterator like instance of either SubscriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_all.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_all_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_all.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_all_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SubscriptionListResult', pipeline_response) + deserialized = self._deserialize("SubscriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,7 +114,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,11 +127,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_all.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions'} # type: ignore + list_all.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions"} # type: ignore + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -139,7 +154,8 @@ async def create_or_update( :param subscription_name: The subscription name. :type subscription_name: str :param parameters: Parameters supplied to create a subscription resource. - :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionCreateOrUpdateParameters + :type parameters: + ~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionCreateOrUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: SubscriptionResource, or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionResource @@ -150,35 +166,31 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SubscriptionCreateOrUpdateParameters') - 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) + + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SubscriptionCreateOrUpdateParameters') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -191,9 +203,12 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}'} # type: ignore - async def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -221,28 +236,27 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -252,8 +266,10 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -282,30 +298,27 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -318,4 +331,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_topics_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_topics_operations.py index 78809361ef44..4552c5af892d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_topics_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_topics_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._topics_operations import build_create_or_update_authorization_rule_request, build_create_or_update_request, build_delete_authorization_rule_request, build_delete_request, build_get_authorization_rule_request, build_get_request, build_list_all_request, build_list_authorization_rules_request, build_list_keys_request, build_post_authorization_rule_request, build_regenerate_keys_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_all( self, resource_group_name: str, @@ -55,44 +60,46 @@ def list_all( :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TopicListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.TopicListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.TopicListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.TopicListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_all.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_all_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_all.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_all_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TopicListResult', pipeline_response) + deserialized = self._deserialize("TopicListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -101,7 +108,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,11 +121,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_all.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics'} # type: ignore + list_all.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics"} # type: ignore + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -143,34 +156,30 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TopicCreateOrUpdateParameters') - 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) + + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TopicCreateOrUpdateParameters') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -183,9 +192,12 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}'} # type: ignore - async def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -210,27 +222,26 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2015-08-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -240,8 +251,10 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -267,29 +280,26 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2015-08-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -302,8 +312,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore + + + @distributed_trace def list_authorization_rules( self, resource_group_name: str, @@ -320,46 +333,50 @@ def list_authorization_rules( :param topic_name: The topic name. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleListResult] + :return: An iterator like instance of either SharedAccessAuthorizationRuleListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessAuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SharedAccessAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SharedAccessAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -368,7 +385,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -377,11 +398,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules"} # type: ignore + @distributed_trace_async async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -402,7 +425,8 @@ async def create_or_update_authorization_rule( :param authorization_rule_name: The authorization rule name. :type authorization_rule_name: str :param parameters: The shared access authorization rule. - :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters + :type parameters: + ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: SharedAccessAuthorizationRuleResource, or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource @@ -413,35 +437,31 @@ async def create_or_update_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SharedAccessAuthorizationRuleCreateOrUpdateParameters') - 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) + + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SharedAccessAuthorizationRuleCreateOrUpdateParameters') + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -454,8 +474,11 @@ async def create_or_update_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}'} # type: ignore + create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace_async async def post_authorization_rule( self, resource_group_name: str, @@ -484,30 +507,27 @@ async def post_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - - # Construct URL - url = self.post_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + + request = build_post_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.post_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -520,8 +540,11 @@ async def post_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - post_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}'} # type: ignore + post_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace_async async def get_authorization_rule( self, resource_group_name: str, @@ -550,30 +573,27 @@ async def get_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -586,9 +606,12 @@ async def get_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}'} # type: ignore - async def delete_authorization_rule( + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace_async + async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -616,28 +639,27 @@ async def delete_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - - # Construct URL - url = self.delete_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -647,8 +669,10 @@ async def delete_authorization_rule( if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}'} # type: ignore + delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + @distributed_trace_async async def list_keys( self, resource_group_name: str, @@ -677,30 +701,27 @@ async def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -713,8 +734,11 @@ async def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore + + + @distributed_trace_async async def regenerate_keys( self, resource_group_name: str, @@ -746,35 +770,31 @@ async def regenerate_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegenerateKeysParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RegenerateKeysParameters') + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -787,4 +807,6 @@ async def regenerate_keys( return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys'} # type: ignore + + regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/models/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/models/__init__.py index 78f57734661b..57408ceb6430 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/models/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/models/__init__.py @@ -6,62 +6,34 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import CheckNameAvailability - from ._models_py3 import CheckNameAvailabilityResult - from ._models_py3 import MessageCountDetails - from ._models_py3 import NamespaceCreateOrUpdateParameters - from ._models_py3 import NamespaceListResult - from ._models_py3 import NamespaceResource - from ._models_py3 import NamespaceUpdateParameters - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationListResult - from ._models_py3 import QueueCreateOrUpdateParameters - from ._models_py3 import QueueListResult - from ._models_py3 import QueueResource - from ._models_py3 import RegenerateKeysParameters - from ._models_py3 import Resource - from ._models_py3 import ResourceListKeys - from ._models_py3 import SharedAccessAuthorizationRuleCreateOrUpdateParameters - from ._models_py3 import SharedAccessAuthorizationRuleListResult - from ._models_py3 import SharedAccessAuthorizationRuleResource - from ._models_py3 import Sku - from ._models_py3 import SubscriptionCreateOrUpdateParameters - from ._models_py3 import SubscriptionListResult - from ._models_py3 import SubscriptionResource - from ._models_py3 import TopicCreateOrUpdateParameters - from ._models_py3 import TopicListResult - from ._models_py3 import TopicResource - from ._models_py3 import TrackedResource -except (SyntaxError, ImportError): - from ._models import CheckNameAvailability # type: ignore - from ._models import CheckNameAvailabilityResult # type: ignore - from ._models import MessageCountDetails # type: ignore - from ._models import NamespaceCreateOrUpdateParameters # type: ignore - from ._models import NamespaceListResult # type: ignore - from ._models import NamespaceResource # type: ignore - from ._models import NamespaceUpdateParameters # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import QueueCreateOrUpdateParameters # type: ignore - from ._models import QueueListResult # type: ignore - from ._models import QueueResource # type: ignore - from ._models import RegenerateKeysParameters # type: ignore - from ._models import Resource # type: ignore - from ._models import ResourceListKeys # type: ignore - from ._models import SharedAccessAuthorizationRuleCreateOrUpdateParameters # type: ignore - from ._models import SharedAccessAuthorizationRuleListResult # type: ignore - from ._models import SharedAccessAuthorizationRuleResource # type: ignore - from ._models import Sku # type: ignore - from ._models import SubscriptionCreateOrUpdateParameters # type: ignore - from ._models import SubscriptionListResult # type: ignore - from ._models import SubscriptionResource # type: ignore - from ._models import TopicCreateOrUpdateParameters # type: ignore - from ._models import TopicListResult # type: ignore - from ._models import TopicResource # type: ignore - from ._models import TrackedResource # type: ignore +from ._models_py3 import CheckNameAvailability +from ._models_py3 import CheckNameAvailabilityResult +from ._models_py3 import MessageCountDetails +from ._models_py3 import NamespaceCreateOrUpdateParameters +from ._models_py3 import NamespaceListResult +from ._models_py3 import NamespaceResource +from ._models_py3 import NamespaceUpdateParameters +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import QueueCreateOrUpdateParameters +from ._models_py3 import QueueListResult +from ._models_py3 import QueueResource +from ._models_py3 import RegenerateKeysParameters +from ._models_py3 import Resource +from ._models_py3 import ResourceListKeys +from ._models_py3 import SharedAccessAuthorizationRuleCreateOrUpdateParameters +from ._models_py3 import SharedAccessAuthorizationRuleListResult +from ._models_py3 import SharedAccessAuthorizationRuleResource +from ._models_py3 import Sku +from ._models_py3 import SubscriptionCreateOrUpdateParameters +from ._models_py3 import SubscriptionListResult +from ._models_py3 import SubscriptionResource +from ._models_py3 import TopicCreateOrUpdateParameters +from ._models_py3 import TopicListResult +from ._models_py3 import TopicResource +from ._models_py3 import TrackedResource + from ._service_bus_management_client_enums import ( AccessRights, diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/models/_models.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/models/_models.py deleted file mode 100644 index 27c852590330..000000000000 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/models/_models.py +++ /dev/null @@ -1,1525 +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 msrest.serialization - - -class CheckNameAvailability(msrest.serialization.Model): - """Description of a Check Name availability request properties. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The Name to check the namespace name availability and The namespace name - can contain only letters, numbers, and hyphens. The namespace must start with a letter, and it - must end with a letter or number. - :type name: str - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CheckNameAvailability, self).__init__(**kwargs) - self.name = kwargs['name'] - - -class CheckNameAvailabilityResult(msrest.serialization.Model): - """Description of a Check Name availability request properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param name_available: Value indicating namespace is availability, true if the namespace is - available; otherwise, false. - :type name_available: bool - :param reason: The reason for unavailability of a namespace. Possible values include: "None", - "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", - "TooManyNamespaceInCurrentSubscription". - :type reason: str or ~azure.mgmt.servicebus.v2015_08_01.models.UnavailableReason - :ivar message: The detailed info regarding the reason associated with the namespace. - :vartype message: str - """ - - _validation = { - 'message': {'readonly': True}, - } - - _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CheckNameAvailabilityResult, self).__init__(**kwargs) - self.name_available = kwargs.get('name_available', None) - self.reason = kwargs.get('reason', None) - self.message = None - - -class MessageCountDetails(msrest.serialization.Model): - """Message Count Details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar active_message_count: Number of active messages in the queue, topic, or subscription. - :vartype active_message_count: long - :ivar dead_letter_message_count: Number of messages that are dead lettered. - :vartype dead_letter_message_count: long - :ivar scheduled_message_count: Number of scheduled messages. - :vartype scheduled_message_count: long - :ivar transfer_dead_letter_message_count: Number of messages transferred into dead letters. - :vartype transfer_dead_letter_message_count: long - :ivar transfer_message_count: Number of messages transferred to another queue, topic, or - subscription. - :vartype transfer_message_count: long - """ - - _validation = { - 'active_message_count': {'readonly': True}, - 'dead_letter_message_count': {'readonly': True}, - 'scheduled_message_count': {'readonly': True}, - 'transfer_dead_letter_message_count': {'readonly': True}, - 'transfer_message_count': {'readonly': True}, - } - - _attribute_map = { - 'active_message_count': {'key': 'activeMessageCount', 'type': 'long'}, - 'dead_letter_message_count': {'key': 'deadLetterMessageCount', 'type': 'long'}, - 'scheduled_message_count': {'key': 'scheduledMessageCount', 'type': 'long'}, - 'transfer_dead_letter_message_count': {'key': 'transferDeadLetterMessageCount', 'type': 'long'}, - 'transfer_message_count': {'key': 'transferMessageCount', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(MessageCountDetails, self).__init__(**kwargs) - self.active_message_count = None - self.dead_letter_message_count = None - self.scheduled_message_count = None - self.transfer_dead_letter_message_count = None - self.transfer_message_count = None - - -class NamespaceCreateOrUpdateParameters(msrest.serialization.Model): - """Parameters supplied to the Create Or Update Namespace operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param location: Required. Namespace location. - :type location: str - :param sku: SKU of the namespace. - :type sku: ~azure.mgmt.servicebus.v2015_08_01.models.Sku - :param tags: A set of tags. Namespace tags. - :type tags: dict[str, str] - :ivar provisioning_state: Provisioning state of the namespace. - :vartype provisioning_state: str - :param status: State of the namespace. Possible values include: "Unknown", "Creating", - "Created", "Activating", "Enabling", "Active", "Disabling", "Disabled", "SoftDeleting", - "SoftDeleted", "Removing", "Removed", "Failed". - :type status: str or ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceState - :ivar created_at: The time the namespace was created. - :vartype created_at: ~datetime.datetime - :ivar updated_at: The time the namespace was updated. - :vartype updated_at: ~datetime.datetime - :ivar service_bus_endpoint: Endpoint you can use to perform Service Bus operations. - :vartype service_bus_endpoint: str - :param create_acs_namespace: Indicates whether to create an ACS namespace. - :type create_acs_namespace: bool - :param enabled: Specifies whether this instance is enabled. - :type enabled: bool - """ - - _validation = { - 'location': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'service_bus_endpoint': {'readonly': True}, - } - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'service_bus_endpoint': {'key': 'properties.serviceBusEndpoint', 'type': 'str'}, - 'create_acs_namespace': {'key': 'properties.createACSNamespace', 'type': 'bool'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(NamespaceCreateOrUpdateParameters, self).__init__(**kwargs) - self.location = kwargs['location'] - self.sku = kwargs.get('sku', None) - self.tags = kwargs.get('tags', None) - self.provisioning_state = None - self.status = kwargs.get('status', None) - self.created_at = None - self.updated_at = None - self.service_bus_endpoint = None - self.create_acs_namespace = kwargs.get('create_acs_namespace', None) - self.enabled = kwargs.get('enabled', None) - - -class NamespaceListResult(msrest.serialization.Model): - """The response of the List Namespace operation. - - :param value: Result of the List Namespace operation. - :type value: list[~azure.mgmt.servicebus.v2015_08_01.models.NamespaceResource] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list - of Namespaces. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[NamespaceResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NamespaceListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class Resource(msrest.serialization.Model): - """The Resource definition for other than namespace. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :param location: Resource location. - :type location: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.location = kwargs.get('location', None) - self.type = None - - -class TrackedResource(Resource): - """The Resource definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :param location: Resource location. - :type location: str - :ivar type: Resource type. - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(TrackedResource, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - - -class NamespaceResource(TrackedResource): - """Description of a namespace resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :param location: Resource location. - :type location: str - :ivar type: Resource type. - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param sku: SKU of the namespace. - :type sku: ~azure.mgmt.servicebus.v2015_08_01.models.Sku - :ivar provisioning_state: Provisioning state of the namespace. - :vartype provisioning_state: str - :param status: State of the namespace. Possible values include: "Unknown", "Creating", - "Created", "Activating", "Enabling", "Active", "Disabling", "Disabled", "SoftDeleting", - "SoftDeleted", "Removing", "Removed", "Failed". - :type status: str or ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceState - :ivar created_at: The time the namespace was created. - :vartype created_at: ~datetime.datetime - :ivar updated_at: The time the namespace was updated. - :vartype updated_at: ~datetime.datetime - :ivar service_bus_endpoint: Endpoint you can use to perform Service Bus operations. - :vartype service_bus_endpoint: str - :param create_acs_namespace: Indicates whether to create an ACS namespace. - :type create_acs_namespace: bool - :param enabled: Specifies whether this instance is enabled. - :type enabled: bool - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'service_bus_endpoint': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'service_bus_endpoint': {'key': 'properties.serviceBusEndpoint', 'type': 'str'}, - 'create_acs_namespace': {'key': 'properties.createACSNamespace', 'type': 'bool'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(NamespaceResource, self).__init__(**kwargs) - self.sku = kwargs.get('sku', None) - self.provisioning_state = None - self.status = kwargs.get('status', None) - self.created_at = None - self.updated_at = None - self.service_bus_endpoint = None - self.create_acs_namespace = kwargs.get('create_acs_namespace', None) - self.enabled = kwargs.get('enabled', None) - - -class NamespaceUpdateParameters(msrest.serialization.Model): - """Parameters supplied to the Patch Namespace operation. - - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param sku: The sku of the created namespace. - :type sku: ~azure.mgmt.servicebus.v2015_08_01.models.Sku - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - } - - def __init__( - self, - **kwargs - ): - super(NamespaceUpdateParameters, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.sku = kwargs.get('sku', None) - - -class Operation(msrest.serialization.Model): - """A ServiceBus REST API operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Operation name: {provider}/{resource}/{operation}. - :vartype name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.servicebus.v2015_08_01.models.OperationDisplay - """ - - _validation = { - 'name': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = None - self.display = kwargs.get('display', None) - - -class OperationDisplay(msrest.serialization.Model): - """The object that represents the operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provider: Service provider: Microsoft.ServiceBus. - :vartype provider: str - :ivar resource: Resource on which the operation is performed: Invoice, etc. - :vartype resource: str - :ivar operation: Operation type: Read, write, delete, etc. - :vartype operation: str - """ - - _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, - } - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - - -class OperationListResult(msrest.serialization.Model): - """Result of the request to list ServiceBus operations. It contains a list of operations and a URL link to get the next set of results. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of ServiceBus operations supported by the Microsoft.ServiceBus resource - provider. - :vartype value: list[~azure.mgmt.servicebus.v2015_08_01.models.Operation] - :ivar next_link: URL to get the next set of operation list results if there are any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class QueueCreateOrUpdateParameters(msrest.serialization.Model): - """Parameters supplied to the Create Or Update Queue operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param name: Queue name. - :type name: str - :param location: Required. location of the resource. - :type location: str - :param lock_duration: The 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: str - :ivar accessed_at: Last time a message was sent, or the last time there was a receive request - to this queue. - :vartype accessed_at: ~datetime.datetime - :param auto_delete_on_idle: the TimeSpan idle interval after which the queue is automatically - deleted. The minimum duration is 5 minutes. - :type auto_delete_on_idle: str - :param entity_availability_status: Entity availability status for the queue. Possible values - include: "Available", "Limited", "Renaming", "Restoring", "Unknown". - :type entity_availability_status: str or - ~azure.mgmt.servicebus.v2015_08_01.models.EntityAvailabilityStatus - :ivar created_at: The exact time the message was created. - :vartype created_at: ~datetime.datetime - :param default_message_time_to_live: The default message time 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: str - :param duplicate_detection_history_time_window: TimeSpan structure that defines the duration of - the duplicate detection history. The default value is 10 minutes. - :type duplicate_detection_history_time_window: str - :param enable_batched_operations: A value that indicates whether server-side batched operations - are enabled. - :type enable_batched_operations: bool - :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 enable_express: A value that indicates whether Express Entities are enabled. An express - queue holds a message in memory temporarily before writing it to persistent storage. - :type enable_express: bool - :param enable_partitioning: A value that indicates whether the queue is to be partitioned - across multiple message brokers. - :type enable_partitioning: bool - :param is_anonymous_accessible: A value that indicates whether the message is accessible - anonymously. - :type is_anonymous_accessible: bool - :param max_delivery_count: The maximum delivery count. A message is automatically deadlettered - after this number of deliveries. - :type max_delivery_count: int - :param max_size_in_megabytes: The maximum size of the queue in megabytes, which is the size of - memory allocated for the queue. - :type max_size_in_megabytes: long - :ivar message_count: The number of messages in the queue. - :vartype message_count: long - :ivar count_details: Message Count Details. - :vartype count_details: ~azure.mgmt.servicebus.v2015_08_01.models.MessageCountDetails - :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 - :ivar size_in_bytes: The size of the queue, in bytes. - :vartype size_in_bytes: long - :param status: Enumerates the possible values for the status of a messaging entity. Possible - values include: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", - "Restoring", "SendDisabled", "Unknown". - :type status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityStatus - :param support_ordering: A value that indicates whether the queue supports ordering. - :type support_ordering: bool - :ivar updated_at: The exact time the message was updated. - :vartype updated_at: ~datetime.datetime - """ - - _validation = { - 'location': {'required': True}, - 'accessed_at': {'readonly': True}, - 'created_at': {'readonly': True}, - 'message_count': {'readonly': True}, - 'count_details': {'readonly': True}, - 'size_in_bytes': {'readonly': True}, - 'updated_at': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'lock_duration': {'key': 'properties.lockDuration', 'type': 'str'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'str'}, - 'entity_availability_status': {'key': 'properties.entityAvailabilityStatus', 'type': 'str'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'str'}, - 'duplicate_detection_history_time_window': {'key': 'properties.duplicateDetectionHistoryTimeWindow', 'type': 'str'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'dead_lettering_on_message_expiration': {'key': 'properties.deadLetteringOnMessageExpiration', 'type': 'bool'}, - 'enable_express': {'key': 'properties.enableExpress', 'type': 'bool'}, - 'enable_partitioning': {'key': 'properties.enablePartitioning', 'type': 'bool'}, - 'is_anonymous_accessible': {'key': 'properties.isAnonymousAccessible', 'type': 'bool'}, - 'max_delivery_count': {'key': 'properties.maxDeliveryCount', 'type': 'int'}, - 'max_size_in_megabytes': {'key': 'properties.maxSizeInMegabytes', 'type': 'long'}, - 'message_count': {'key': 'properties.messageCount', 'type': 'long'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'requires_duplicate_detection': {'key': 'properties.requiresDuplicateDetection', 'type': 'bool'}, - 'requires_session': {'key': 'properties.requiresSession', 'type': 'bool'}, - 'size_in_bytes': {'key': 'properties.sizeInBytes', 'type': 'long'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'support_ordering': {'key': 'properties.supportOrdering', 'type': 'bool'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(QueueCreateOrUpdateParameters, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.location = kwargs['location'] - self.lock_duration = kwargs.get('lock_duration', None) - self.accessed_at = None - self.auto_delete_on_idle = kwargs.get('auto_delete_on_idle', None) - self.entity_availability_status = kwargs.get('entity_availability_status', None) - self.created_at = None - self.default_message_time_to_live = kwargs.get('default_message_time_to_live', None) - self.duplicate_detection_history_time_window = kwargs.get('duplicate_detection_history_time_window', None) - self.enable_batched_operations = kwargs.get('enable_batched_operations', None) - self.dead_lettering_on_message_expiration = kwargs.get('dead_lettering_on_message_expiration', None) - self.enable_express = kwargs.get('enable_express', None) - self.enable_partitioning = kwargs.get('enable_partitioning', None) - self.is_anonymous_accessible = kwargs.get('is_anonymous_accessible', None) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - self.max_size_in_megabytes = kwargs.get('max_size_in_megabytes', None) - self.message_count = None - self.count_details = None - self.requires_duplicate_detection = kwargs.get('requires_duplicate_detection', None) - self.requires_session = kwargs.get('requires_session', None) - self.size_in_bytes = None - self.status = kwargs.get('status', None) - self.support_ordering = kwargs.get('support_ordering', None) - self.updated_at = None - - -class QueueListResult(msrest.serialization.Model): - """The response to the List Queues operation. - - :param value: Result of the List Queues operation. - :type value: list[~azure.mgmt.servicebus.v2015_08_01.models.QueueResource] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list - of queues. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[QueueResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(QueueListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class QueueResource(Resource): - """Description of queue Resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :param location: Resource location. - :type location: str - :ivar type: Resource type. - :vartype type: str - :param lock_duration: The 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: str - :ivar accessed_at: Last time a message was sent, or the last time there was a receive request - to this queue. - :vartype accessed_at: ~datetime.datetime - :param auto_delete_on_idle: the TimeSpan idle interval after which the queue is automatically - deleted. The minimum duration is 5 minutes. - :type auto_delete_on_idle: str - :param entity_availability_status: Entity availability status for the queue. Possible values - include: "Available", "Limited", "Renaming", "Restoring", "Unknown". - :type entity_availability_status: str or - ~azure.mgmt.servicebus.v2015_08_01.models.EntityAvailabilityStatus - :ivar created_at: The exact time the message was created. - :vartype created_at: ~datetime.datetime - :param default_message_time_to_live: The default message time 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: str - :param duplicate_detection_history_time_window: TimeSpan structure that defines the duration of - the duplicate detection history. The default value is 10 minutes. - :type duplicate_detection_history_time_window: str - :param enable_batched_operations: A value that indicates whether server-side batched operations - are enabled. - :type enable_batched_operations: bool - :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 enable_express: A value that indicates whether Express Entities are enabled. An express - queue holds a message in memory temporarily before writing it to persistent storage. - :type enable_express: bool - :param enable_partitioning: A value that indicates whether the queue is to be partitioned - across multiple message brokers. - :type enable_partitioning: bool - :param is_anonymous_accessible: A value that indicates whether the message is accessible - anonymously. - :type is_anonymous_accessible: bool - :param max_delivery_count: The maximum delivery count. A message is automatically deadlettered - after this number of deliveries. - :type max_delivery_count: int - :param max_size_in_megabytes: The maximum size of the queue in megabytes, which is the size of - memory allocated for the queue. - :type max_size_in_megabytes: long - :ivar message_count: The number of messages in the queue. - :vartype message_count: long - :ivar count_details: Message Count Details. - :vartype count_details: ~azure.mgmt.servicebus.v2015_08_01.models.MessageCountDetails - :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 - :ivar size_in_bytes: The size of the queue, in bytes. - :vartype size_in_bytes: long - :param status: Enumerates the possible values for the status of a messaging entity. Possible - values include: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", - "Restoring", "SendDisabled", "Unknown". - :type status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityStatus - :param support_ordering: A value that indicates whether the queue supports ordering. - :type support_ordering: bool - :ivar updated_at: The exact time the message was updated. - :vartype updated_at: ~datetime.datetime - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'accessed_at': {'readonly': True}, - 'created_at': {'readonly': True}, - 'message_count': {'readonly': True}, - 'count_details': {'readonly': True}, - 'size_in_bytes': {'readonly': True}, - 'updated_at': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'lock_duration': {'key': 'properties.lockDuration', 'type': 'str'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'str'}, - 'entity_availability_status': {'key': 'properties.entityAvailabilityStatus', 'type': 'str'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'str'}, - 'duplicate_detection_history_time_window': {'key': 'properties.duplicateDetectionHistoryTimeWindow', 'type': 'str'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'dead_lettering_on_message_expiration': {'key': 'properties.deadLetteringOnMessageExpiration', 'type': 'bool'}, - 'enable_express': {'key': 'properties.enableExpress', 'type': 'bool'}, - 'enable_partitioning': {'key': 'properties.enablePartitioning', 'type': 'bool'}, - 'is_anonymous_accessible': {'key': 'properties.isAnonymousAccessible', 'type': 'bool'}, - 'max_delivery_count': {'key': 'properties.maxDeliveryCount', 'type': 'int'}, - 'max_size_in_megabytes': {'key': 'properties.maxSizeInMegabytes', 'type': 'long'}, - 'message_count': {'key': 'properties.messageCount', 'type': 'long'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'requires_duplicate_detection': {'key': 'properties.requiresDuplicateDetection', 'type': 'bool'}, - 'requires_session': {'key': 'properties.requiresSession', 'type': 'bool'}, - 'size_in_bytes': {'key': 'properties.sizeInBytes', 'type': 'long'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'support_ordering': {'key': 'properties.supportOrdering', 'type': 'bool'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(QueueResource, self).__init__(**kwargs) - self.lock_duration = kwargs.get('lock_duration', None) - self.accessed_at = None - self.auto_delete_on_idle = kwargs.get('auto_delete_on_idle', None) - self.entity_availability_status = kwargs.get('entity_availability_status', None) - self.created_at = None - self.default_message_time_to_live = kwargs.get('default_message_time_to_live', None) - self.duplicate_detection_history_time_window = kwargs.get('duplicate_detection_history_time_window', None) - self.enable_batched_operations = kwargs.get('enable_batched_operations', None) - self.dead_lettering_on_message_expiration = kwargs.get('dead_lettering_on_message_expiration', None) - self.enable_express = kwargs.get('enable_express', None) - self.enable_partitioning = kwargs.get('enable_partitioning', None) - self.is_anonymous_accessible = kwargs.get('is_anonymous_accessible', None) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - self.max_size_in_megabytes = kwargs.get('max_size_in_megabytes', None) - self.message_count = None - self.count_details = None - self.requires_duplicate_detection = kwargs.get('requires_duplicate_detection', None) - self.requires_session = kwargs.get('requires_session', None) - self.size_in_bytes = None - self.status = kwargs.get('status', None) - self.support_ordering = kwargs.get('support_ordering', None) - self.updated_at = None - - -class RegenerateKeysParameters(msrest.serialization.Model): - """Parameters supplied to the Regenerate Authorization Rule operation. - - :param policykey: Key that needs to be regenerated. Possible values include: "PrimaryKey", - "SecondaryKey". - :type policykey: str or ~azure.mgmt.servicebus.v2015_08_01.models.Policykey - """ - - _attribute_map = { - 'policykey': {'key': 'Policykey', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RegenerateKeysParameters, self).__init__(**kwargs) - self.policykey = kwargs.get('policykey', None) - - -class ResourceListKeys(msrest.serialization.Model): - """Namespace/ServiceBus Connection String. - - :param primary_connection_string: Primary connection string of the created namespace - authorization rule. - :type primary_connection_string: str - :param secondary_connection_string: Secondary connection string of the created namespace - authorization rule. - :type secondary_connection_string: str - :param primary_key: A base64-encoded 256-bit primary key for signing and validating the SAS - token. - :type primary_key: str - :param secondary_key: A base64-encoded 256-bit primary key for signing and validating the SAS - token. - :type secondary_key: str - :param key_name: A string that describes the authorization rule. - :type key_name: str - """ - - _attribute_map = { - 'primary_connection_string': {'key': 'primaryConnectionString', 'type': 'str'}, - 'secondary_connection_string': {'key': 'secondaryConnectionString', 'type': 'str'}, - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, - 'key_name': {'key': 'keyName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceListKeys, self).__init__(**kwargs) - self.primary_connection_string = kwargs.get('primary_connection_string', None) - self.secondary_connection_string = kwargs.get('secondary_connection_string', None) - self.primary_key = kwargs.get('primary_key', None) - self.secondary_key = kwargs.get('secondary_key', None) - self.key_name = kwargs.get('key_name', None) - - -class SharedAccessAuthorizationRuleCreateOrUpdateParameters(msrest.serialization.Model): - """Parameters supplied to the Create Or Update Authorization Rules operation. - - :param location: data center location. - :type location: str - :param name: Name of the authorization rule. - :type name: str - :param rights: The rights associated with the rule. - :type rights: list[str or ~azure.mgmt.servicebus.v2015_08_01.models.AccessRights] - """ - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'rights': {'key': 'properties.rights', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(SharedAccessAuthorizationRuleCreateOrUpdateParameters, self).__init__(**kwargs) - self.location = kwargs.get('location', None) - self.name = kwargs.get('name', None) - self.rights = kwargs.get('rights', None) - - -class SharedAccessAuthorizationRuleListResult(msrest.serialization.Model): - """The response to the List Namespace operation. - - :param value: Result of the List Authorization Rules operation. - :type value: - list[~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list - of Authorization Rules. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SharedAccessAuthorizationRuleResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SharedAccessAuthorizationRuleListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class SharedAccessAuthorizationRuleResource(Resource): - """Description of a namespace authorization rule. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :param location: Resource location. - :type location: str - :ivar type: Resource type. - :vartype type: str - :param rights: The rights associated with the rule. - :type rights: list[str or ~azure.mgmt.servicebus.v2015_08_01.models.AccessRights] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'rights': {'key': 'properties.rights', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(SharedAccessAuthorizationRuleResource, self).__init__(**kwargs) - self.rights = kwargs.get('rights', None) - - -class Sku(msrest.serialization.Model): - """SKU of the namespace. - - All required parameters must be populated in order to send to Azure. - - :param name: Name of this SKU. Possible values include: "Basic", "Standard", "Premium". - :type name: str or ~azure.mgmt.servicebus.v2015_08_01.models.SkuName - :param tier: Required. The billing tier of this particular SKU. Possible values include: - "Basic", "Standard", "Premium". - :type tier: str or ~azure.mgmt.servicebus.v2015_08_01.models.SkuTier - :param capacity: The specified messaging units for the tier. - :type capacity: int - """ - - _validation = { - 'tier': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(Sku, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.tier = kwargs['tier'] - self.capacity = kwargs.get('capacity', None) - - -class SubscriptionCreateOrUpdateParameters(msrest.serialization.Model): - """Parameters supplied to the Create Or Update Subscription operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param location: Required. Subscription data center location. - :type location: str - :param type: Resource manager type of the resource. - :type type: str - :ivar accessed_at: Last time there was a receive request to this subscription. - :vartype accessed_at: ~datetime.datetime - :param auto_delete_on_idle: TimeSpan idle interval after which the topic is automatically - deleted. The minimum duration is 5 minutes. - :type auto_delete_on_idle: str - :ivar count_details: Message Count Details. - :vartype count_details: ~azure.mgmt.servicebus.v2015_08_01.models.MessageCountDetails - :ivar created_at: Exact time the message was created. - :vartype created_at: ~datetime.datetime - :param default_message_time_to_live: Default message time 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: str - :param dead_lettering_on_filter_evaluation_exceptions: Value that indicates whether a - subscription has dead letter support on filter evaluation exceptions. - :type dead_lettering_on_filter_evaluation_exceptions: bool - :param dead_lettering_on_message_expiration: Value that indicates whether a subscription has - dead letter support when a message expires. - :type dead_lettering_on_message_expiration: bool - :param enable_batched_operations: Value that indicates whether server-side batched operations - are enabled. - :type enable_batched_operations: bool - :param entity_availability_status: Entity availability status for the topic. Possible values - include: "Available", "Limited", "Renaming", "Restoring", "Unknown". - :type entity_availability_status: str or - ~azure.mgmt.servicebus.v2015_08_01.models.EntityAvailabilityStatus - :param is_read_only: Value that indicates whether the entity description is read-only. - :type is_read_only: bool - :param lock_duration: The lock duration time span for the subscription. - :type lock_duration: str - :param max_delivery_count: Number of maximum deliveries. - :type max_delivery_count: int - :ivar message_count: Number of messages. - :vartype message_count: long - :param requires_session: Value indicating if a subscription supports the concept of sessions. - :type requires_session: bool - :param status: Enumerates the possible values for the status of a messaging entity. Possible - values include: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", - "Restoring", "SendDisabled", "Unknown". - :type status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityStatus - :ivar updated_at: The exact time the message was updated. - :vartype updated_at: ~datetime.datetime - """ - - _validation = { - 'location': {'required': True}, - 'accessed_at': {'readonly': True}, - 'count_details': {'readonly': True}, - 'created_at': {'readonly': True}, - 'message_count': {'readonly': True}, - 'updated_at': {'readonly': True}, - } - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'str'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'str'}, - 'dead_lettering_on_filter_evaluation_exceptions': {'key': 'properties.deadLetteringOnFilterEvaluationExceptions', 'type': 'bool'}, - 'dead_lettering_on_message_expiration': {'key': 'properties.deadLetteringOnMessageExpiration', 'type': 'bool'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'entity_availability_status': {'key': 'properties.entityAvailabilityStatus', 'type': 'str'}, - 'is_read_only': {'key': 'properties.isReadOnly', 'type': 'bool'}, - 'lock_duration': {'key': 'properties.lockDuration', 'type': 'str'}, - 'max_delivery_count': {'key': 'properties.maxDeliveryCount', 'type': 'int'}, - 'message_count': {'key': 'properties.messageCount', 'type': 'long'}, - 'requires_session': {'key': 'properties.requiresSession', 'type': 'bool'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(SubscriptionCreateOrUpdateParameters, self).__init__(**kwargs) - self.location = kwargs['location'] - self.type = kwargs.get('type', None) - self.accessed_at = None - self.auto_delete_on_idle = kwargs.get('auto_delete_on_idle', None) - self.count_details = None - self.created_at = None - self.default_message_time_to_live = kwargs.get('default_message_time_to_live', None) - self.dead_lettering_on_filter_evaluation_exceptions = kwargs.get('dead_lettering_on_filter_evaluation_exceptions', None) - self.dead_lettering_on_message_expiration = kwargs.get('dead_lettering_on_message_expiration', None) - self.enable_batched_operations = kwargs.get('enable_batched_operations', None) - self.entity_availability_status = kwargs.get('entity_availability_status', None) - self.is_read_only = kwargs.get('is_read_only', None) - self.lock_duration = kwargs.get('lock_duration', None) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - self.message_count = None - self.requires_session = kwargs.get('requires_session', None) - self.status = kwargs.get('status', None) - self.updated_at = None - - -class SubscriptionListResult(msrest.serialization.Model): - """The response to the List Subscriptions operation. - - :param value: Result of the List Subscriptions operation. - :type value: list[~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionResource] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list - of subscriptions. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SubscriptionResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SubscriptionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class SubscriptionResource(Resource): - """Description of subscription resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :param location: Resource location. - :type location: str - :ivar type: Resource type. - :vartype type: str - :ivar accessed_at: Last time there was a receive request to this subscription. - :vartype accessed_at: ~datetime.datetime - :param auto_delete_on_idle: TimeSpan idle interval after which the topic is automatically - deleted. The minimum duration is 5 minutes. - :type auto_delete_on_idle: str - :ivar count_details: Message Count Details. - :vartype count_details: ~azure.mgmt.servicebus.v2015_08_01.models.MessageCountDetails - :ivar created_at: Exact time the message was created. - :vartype created_at: ~datetime.datetime - :param default_message_time_to_live: Default message time 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: str - :param dead_lettering_on_filter_evaluation_exceptions: Value that indicates whether a - subscription has dead letter support on filter evaluation exceptions. - :type dead_lettering_on_filter_evaluation_exceptions: bool - :param dead_lettering_on_message_expiration: Value that indicates whether a subscription has - dead letter support when a message expires. - :type dead_lettering_on_message_expiration: bool - :param enable_batched_operations: Value that indicates whether server-side batched operations - are enabled. - :type enable_batched_operations: bool - :param entity_availability_status: Entity availability status for the topic. Possible values - include: "Available", "Limited", "Renaming", "Restoring", "Unknown". - :type entity_availability_status: str or - ~azure.mgmt.servicebus.v2015_08_01.models.EntityAvailabilityStatus - :param is_read_only: Value that indicates whether the entity description is read-only. - :type is_read_only: bool - :param lock_duration: The lock duration time span for the subscription. - :type lock_duration: str - :param max_delivery_count: Number of maximum deliveries. - :type max_delivery_count: int - :ivar message_count: Number of messages. - :vartype message_count: long - :param requires_session: Value indicating if a subscription supports the concept of sessions. - :type requires_session: bool - :param status: Enumerates the possible values for the status of a messaging entity. Possible - values include: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", - "Restoring", "SendDisabled", "Unknown". - :type status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityStatus - :ivar updated_at: The exact time the message was updated. - :vartype updated_at: ~datetime.datetime - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'accessed_at': {'readonly': True}, - 'count_details': {'readonly': True}, - 'created_at': {'readonly': True}, - 'message_count': {'readonly': True}, - 'updated_at': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'str'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'str'}, - 'dead_lettering_on_filter_evaluation_exceptions': {'key': 'properties.deadLetteringOnFilterEvaluationExceptions', 'type': 'bool'}, - 'dead_lettering_on_message_expiration': {'key': 'properties.deadLetteringOnMessageExpiration', 'type': 'bool'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'entity_availability_status': {'key': 'properties.entityAvailabilityStatus', 'type': 'str'}, - 'is_read_only': {'key': 'properties.isReadOnly', 'type': 'bool'}, - 'lock_duration': {'key': 'properties.lockDuration', 'type': 'str'}, - 'max_delivery_count': {'key': 'properties.maxDeliveryCount', 'type': 'int'}, - 'message_count': {'key': 'properties.messageCount', 'type': 'long'}, - 'requires_session': {'key': 'properties.requiresSession', 'type': 'bool'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(SubscriptionResource, self).__init__(**kwargs) - self.accessed_at = None - self.auto_delete_on_idle = kwargs.get('auto_delete_on_idle', None) - self.count_details = None - self.created_at = None - self.default_message_time_to_live = kwargs.get('default_message_time_to_live', None) - self.dead_lettering_on_filter_evaluation_exceptions = kwargs.get('dead_lettering_on_filter_evaluation_exceptions', None) - self.dead_lettering_on_message_expiration = kwargs.get('dead_lettering_on_message_expiration', None) - self.enable_batched_operations = kwargs.get('enable_batched_operations', None) - self.entity_availability_status = kwargs.get('entity_availability_status', None) - self.is_read_only = kwargs.get('is_read_only', None) - self.lock_duration = kwargs.get('lock_duration', None) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - self.message_count = None - self.requires_session = kwargs.get('requires_session', None) - self.status = kwargs.get('status', None) - self.updated_at = None - - -class TopicCreateOrUpdateParameters(msrest.serialization.Model): - """Parameters supplied to the Create Or Update Topic operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param name: Topic name. - :type name: str - :param location: Required. Location of the resource. - :type location: str - :ivar accessed_at: Last time the message was sent, or a request was received, for this topic. - :vartype accessed_at: ~datetime.datetime - :param auto_delete_on_idle: TimeSpan idle interval after which the topic is automatically - deleted. The minimum duration is 5 minutes. - :type auto_delete_on_idle: str - :param entity_availability_status: Entity availability status for the topic. Possible values - include: "Available", "Limited", "Renaming", "Restoring", "Unknown". - :type entity_availability_status: str or - ~azure.mgmt.servicebus.v2015_08_01.models.EntityAvailabilityStatus - :ivar created_at: Exact time the message was created. - :vartype created_at: ~datetime.datetime - :ivar count_details: Message Count Details. - :vartype count_details: ~azure.mgmt.servicebus.v2015_08_01.models.MessageCountDetails - :param default_message_time_to_live: Default message time 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: str - :param duplicate_detection_history_time_window: TimeSpan structure that defines the duration of - the duplicate detection history. The default value is 10 minutes. - :type duplicate_detection_history_time_window: str - :param enable_batched_operations: Value that indicates whether server-side batched operations - are enabled. - :type enable_batched_operations: bool - :param enable_express: 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 enable_partitioning: Value that indicates whether the topic to be partitioned across - multiple message brokers is enabled. - :type enable_partitioning: bool - :param filtering_messages_before_publishing: Whether messages should be filtered before - publishing. - :type filtering_messages_before_publishing: bool - :param is_anonymous_accessible: Value that indicates whether the message is accessible - anonymously. - :type is_anonymous_accessible: bool - :param is_express: - :type is_express: bool - :param max_size_in_megabytes: Maximum size of the topic in megabytes, which is the size of the - memory allocated for the topic. - :type max_size_in_megabytes: long - :param requires_duplicate_detection: Value indicating if this topic requires duplicate - detection. - :type requires_duplicate_detection: bool - :ivar size_in_bytes: Size of the topic, in bytes. - :vartype size_in_bytes: long - :param status: Enumerates the possible values for the status of a messaging entity. Possible - values include: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", - "Restoring", "SendDisabled", "Unknown". - :type status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityStatus - :ivar subscription_count: Number of subscriptions. - :vartype subscription_count: int - :param support_ordering: Value that indicates whether the topic supports ordering. - :type support_ordering: bool - :ivar updated_at: The exact time the message was updated. - :vartype updated_at: ~datetime.datetime - """ - - _validation = { - 'location': {'required': True}, - 'accessed_at': {'readonly': True}, - 'created_at': {'readonly': True}, - 'count_details': {'readonly': True}, - 'size_in_bytes': {'readonly': True}, - 'subscription_count': {'readonly': True}, - 'updated_at': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'str'}, - 'entity_availability_status': {'key': 'properties.entityAvailabilityStatus', 'type': 'str'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'str'}, - 'duplicate_detection_history_time_window': {'key': 'properties.duplicateDetectionHistoryTimeWindow', 'type': 'str'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'enable_express': {'key': 'properties.enableExpress', 'type': 'bool'}, - 'enable_partitioning': {'key': 'properties.enablePartitioning', 'type': 'bool'}, - 'filtering_messages_before_publishing': {'key': 'properties.filteringMessagesBeforePublishing', 'type': 'bool'}, - 'is_anonymous_accessible': {'key': 'properties.isAnonymousAccessible', 'type': 'bool'}, - 'is_express': {'key': 'properties.isExpress', 'type': 'bool'}, - 'max_size_in_megabytes': {'key': 'properties.maxSizeInMegabytes', 'type': 'long'}, - 'requires_duplicate_detection': {'key': 'properties.requiresDuplicateDetection', 'type': 'bool'}, - 'size_in_bytes': {'key': 'properties.sizeInBytes', 'type': 'long'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'subscription_count': {'key': 'properties.subscriptionCount', 'type': 'int'}, - 'support_ordering': {'key': 'properties.supportOrdering', 'type': 'bool'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(TopicCreateOrUpdateParameters, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.location = kwargs['location'] - self.accessed_at = None - self.auto_delete_on_idle = kwargs.get('auto_delete_on_idle', None) - self.entity_availability_status = kwargs.get('entity_availability_status', None) - self.created_at = None - self.count_details = None - self.default_message_time_to_live = kwargs.get('default_message_time_to_live', None) - self.duplicate_detection_history_time_window = kwargs.get('duplicate_detection_history_time_window', None) - self.enable_batched_operations = kwargs.get('enable_batched_operations', None) - self.enable_express = kwargs.get('enable_express', None) - self.enable_partitioning = kwargs.get('enable_partitioning', None) - self.filtering_messages_before_publishing = kwargs.get('filtering_messages_before_publishing', None) - self.is_anonymous_accessible = kwargs.get('is_anonymous_accessible', None) - self.is_express = kwargs.get('is_express', None) - self.max_size_in_megabytes = kwargs.get('max_size_in_megabytes', None) - self.requires_duplicate_detection = kwargs.get('requires_duplicate_detection', None) - self.size_in_bytes = None - self.status = kwargs.get('status', None) - self.subscription_count = None - self.support_ordering = kwargs.get('support_ordering', None) - self.updated_at = None - - -class TopicListResult(msrest.serialization.Model): - """The response to the List Topics operation. - - :param value: Result of the List Topics operation. - :type value: list[~azure.mgmt.servicebus.v2015_08_01.models.TopicResource] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list - of topics. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[TopicResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TopicListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class TopicResource(Resource): - """Description of topic resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :param location: Resource location. - :type location: str - :ivar type: Resource type. - :vartype type: str - :ivar accessed_at: Last time the message was sent, or a request was received, for this topic. - :vartype accessed_at: ~datetime.datetime - :param auto_delete_on_idle: TimeSpan idle interval after which the topic is automatically - deleted. The minimum duration is 5 minutes. - :type auto_delete_on_idle: str - :param entity_availability_status: Entity availability status for the topic. Possible values - include: "Available", "Limited", "Renaming", "Restoring", "Unknown". - :type entity_availability_status: str or - ~azure.mgmt.servicebus.v2015_08_01.models.EntityAvailabilityStatus - :ivar created_at: Exact time the message was created. - :vartype created_at: ~datetime.datetime - :ivar count_details: Message Count Details. - :vartype count_details: ~azure.mgmt.servicebus.v2015_08_01.models.MessageCountDetails - :param default_message_time_to_live: Default message time 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: str - :param duplicate_detection_history_time_window: TimeSpan structure that defines the duration of - the duplicate detection history. The default value is 10 minutes. - :type duplicate_detection_history_time_window: str - :param enable_batched_operations: Value that indicates whether server-side batched operations - are enabled. - :type enable_batched_operations: bool - :param enable_express: 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 enable_partitioning: Value that indicates whether the topic to be partitioned across - multiple message brokers is enabled. - :type enable_partitioning: bool - :param filtering_messages_before_publishing: Whether messages should be filtered before - publishing. - :type filtering_messages_before_publishing: bool - :param is_anonymous_accessible: Value that indicates whether the message is accessible - anonymously. - :type is_anonymous_accessible: bool - :param is_express: - :type is_express: bool - :param max_size_in_megabytes: Maximum size of the topic in megabytes, which is the size of the - memory allocated for the topic. - :type max_size_in_megabytes: long - :param requires_duplicate_detection: Value indicating if this topic requires duplicate - detection. - :type requires_duplicate_detection: bool - :ivar size_in_bytes: Size of the topic, in bytes. - :vartype size_in_bytes: long - :param status: Enumerates the possible values for the status of a messaging entity. Possible - values include: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", - "Restoring", "SendDisabled", "Unknown". - :type status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityStatus - :ivar subscription_count: Number of subscriptions. - :vartype subscription_count: int - :param support_ordering: Value that indicates whether the topic supports ordering. - :type support_ordering: bool - :ivar updated_at: The exact time the message was updated. - :vartype updated_at: ~datetime.datetime - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'accessed_at': {'readonly': True}, - 'created_at': {'readonly': True}, - 'count_details': {'readonly': True}, - 'size_in_bytes': {'readonly': True}, - 'subscription_count': {'readonly': True}, - 'updated_at': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'str'}, - 'entity_availability_status': {'key': 'properties.entityAvailabilityStatus', 'type': 'str'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'str'}, - 'duplicate_detection_history_time_window': {'key': 'properties.duplicateDetectionHistoryTimeWindow', 'type': 'str'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'enable_express': {'key': 'properties.enableExpress', 'type': 'bool'}, - 'enable_partitioning': {'key': 'properties.enablePartitioning', 'type': 'bool'}, - 'filtering_messages_before_publishing': {'key': 'properties.filteringMessagesBeforePublishing', 'type': 'bool'}, - 'is_anonymous_accessible': {'key': 'properties.isAnonymousAccessible', 'type': 'bool'}, - 'is_express': {'key': 'properties.isExpress', 'type': 'bool'}, - 'max_size_in_megabytes': {'key': 'properties.maxSizeInMegabytes', 'type': 'long'}, - 'requires_duplicate_detection': {'key': 'properties.requiresDuplicateDetection', 'type': 'bool'}, - 'size_in_bytes': {'key': 'properties.sizeInBytes', 'type': 'long'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'subscription_count': {'key': 'properties.subscriptionCount', 'type': 'int'}, - 'support_ordering': {'key': 'properties.supportOrdering', 'type': 'bool'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(TopicResource, self).__init__(**kwargs) - self.accessed_at = None - self.auto_delete_on_idle = kwargs.get('auto_delete_on_idle', None) - self.entity_availability_status = kwargs.get('entity_availability_status', None) - self.created_at = None - self.count_details = None - self.default_message_time_to_live = kwargs.get('default_message_time_to_live', None) - self.duplicate_detection_history_time_window = kwargs.get('duplicate_detection_history_time_window', None) - self.enable_batched_operations = kwargs.get('enable_batched_operations', None) - self.enable_express = kwargs.get('enable_express', None) - self.enable_partitioning = kwargs.get('enable_partitioning', None) - self.filtering_messages_before_publishing = kwargs.get('filtering_messages_before_publishing', None) - self.is_anonymous_accessible = kwargs.get('is_anonymous_accessible', None) - self.is_express = kwargs.get('is_express', None) - self.max_size_in_megabytes = kwargs.get('max_size_in_megabytes', None) - self.requires_duplicate_detection = kwargs.get('requires_duplicate_detection', None) - self.size_in_bytes = None - self.status = kwargs.get('status', None) - self.subscription_count = None - self.support_ordering = kwargs.get('support_ordering', None) - self.updated_at = None diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/models/_models_py3.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/models/_models_py3.py index 2b2c32db4e79..8b66d7354ab4 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/models/_models_py3.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/models/_models_py3.py @@ -18,10 +18,10 @@ class CheckNameAvailability(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The Name to check the namespace name availability and The namespace name + :ivar name: Required. The Name to check the namespace name availability and The namespace name can contain only letters, numbers, and hyphens. The namespace must start with a letter, and it must end with a letter or number. - :type name: str + :vartype name: str """ _validation = { @@ -38,6 +38,12 @@ def __init__( name: str, **kwargs ): + """ + :keyword name: Required. The Name to check the namespace name availability and The namespace + name can contain only letters, numbers, and hyphens. The namespace must start with a letter, + and it must end with a letter or number. + :paramtype name: str + """ super(CheckNameAvailability, self).__init__(**kwargs) self.name = name @@ -47,13 +53,13 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param name_available: Value indicating namespace is availability, true if the namespace is + :ivar name_available: Value indicating namespace is availability, true if the namespace is available; otherwise, false. - :type name_available: bool - :param reason: The reason for unavailability of a namespace. Possible values include: "None", + :vartype name_available: bool + :ivar reason: The reason for unavailability of a namespace. Possible values include: "None", "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", "TooManyNamespaceInCurrentSubscription". - :type reason: str or ~azure.mgmt.servicebus.v2015_08_01.models.UnavailableReason + :vartype reason: str or ~azure.mgmt.servicebus.v2015_08_01.models.UnavailableReason :ivar message: The detailed info regarding the reason associated with the namespace. :vartype message: str """ @@ -75,6 +81,15 @@ def __init__( reason: Optional[Union[str, "UnavailableReason"]] = None, **kwargs ): + """ + :keyword name_available: Value indicating namespace is availability, true if the namespace is + available; otherwise, false. + :paramtype name_available: bool + :keyword reason: The reason for unavailability of a namespace. Possible values include: "None", + "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", + "TooManyNamespaceInCurrentSubscription". + :paramtype reason: str or ~azure.mgmt.servicebus.v2015_08_01.models.UnavailableReason + """ super(CheckNameAvailabilityResult, self).__init__(**kwargs) self.name_available = name_available self.reason = reason @@ -119,6 +134,8 @@ def __init__( self, **kwargs ): + """ + """ super(MessageCountDetails, self).__init__(**kwargs) self.active_message_count = None self.dead_letter_message_count = None @@ -134,28 +151,28 @@ class NamespaceCreateOrUpdateParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: Required. Namespace location. - :type location: str - :param sku: SKU of the namespace. - :type sku: ~azure.mgmt.servicebus.v2015_08_01.models.Sku - :param tags: A set of tags. Namespace tags. - :type tags: dict[str, str] + :ivar location: Required. Namespace location. + :vartype location: str + :ivar sku: SKU of the namespace. + :vartype sku: ~azure.mgmt.servicebus.v2015_08_01.models.Sku + :ivar tags: A set of tags. Namespace tags. + :vartype tags: dict[str, str] :ivar provisioning_state: Provisioning state of the namespace. :vartype provisioning_state: str - :param status: State of the namespace. Possible values include: "Unknown", "Creating", + :ivar status: State of the namespace. Possible values include: "Unknown", "Creating", "Created", "Activating", "Enabling", "Active", "Disabling", "Disabled", "SoftDeleting", "SoftDeleted", "Removing", "Removed", "Failed". - :type status: str or ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceState + :vartype status: str or ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceState :ivar created_at: The time the namespace was created. :vartype created_at: ~datetime.datetime :ivar updated_at: The time the namespace was updated. :vartype updated_at: ~datetime.datetime :ivar service_bus_endpoint: Endpoint you can use to perform Service Bus operations. :vartype service_bus_endpoint: str - :param create_acs_namespace: Indicates whether to create an ACS namespace. - :type create_acs_namespace: bool - :param enabled: Specifies whether this instance is enabled. - :type enabled: bool + :ivar create_acs_namespace: Indicates whether to create an ACS namespace. + :vartype create_acs_namespace: bool + :ivar enabled: Specifies whether this instance is enabled. + :vartype enabled: bool """ _validation = { @@ -190,6 +207,22 @@ def __init__( enabled: Optional[bool] = None, **kwargs ): + """ + :keyword location: Required. Namespace location. + :paramtype location: str + :keyword sku: SKU of the namespace. + :paramtype sku: ~azure.mgmt.servicebus.v2015_08_01.models.Sku + :keyword tags: A set of tags. Namespace tags. + :paramtype tags: dict[str, str] + :keyword status: State of the namespace. Possible values include: "Unknown", "Creating", + "Created", "Activating", "Enabling", "Active", "Disabling", "Disabled", "SoftDeleting", + "SoftDeleted", "Removing", "Removed", "Failed". + :paramtype status: str or ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceState + :keyword create_acs_namespace: Indicates whether to create an ACS namespace. + :paramtype create_acs_namespace: bool + :keyword enabled: Specifies whether this instance is enabled. + :paramtype enabled: bool + """ super(NamespaceCreateOrUpdateParameters, self).__init__(**kwargs) self.location = location self.sku = sku @@ -206,11 +239,11 @@ def __init__( class NamespaceListResult(msrest.serialization.Model): """The response of the List Namespace operation. - :param value: Result of the List Namespace operation. - :type value: list[~azure.mgmt.servicebus.v2015_08_01.models.NamespaceResource] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list + :ivar value: Result of the List Namespace operation. + :vartype value: list[~azure.mgmt.servicebus.v2015_08_01.models.NamespaceResource] + :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of Namespaces. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -225,6 +258,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of the List Namespace operation. + :paramtype value: list[~azure.mgmt.servicebus.v2015_08_01.models.NamespaceResource] + :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete + list of Namespaces. + :paramtype next_link: str + """ super(NamespaceListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -239,8 +279,8 @@ class Resource(msrest.serialization.Model): :vartype id: str :ivar name: Resource name. :vartype name: str - :param location: Resource location. - :type location: str + :ivar location: Resource location. + :vartype location: str :ivar type: Resource type. :vartype type: str """ @@ -264,6 +304,10 @@ def __init__( location: Optional[str] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -280,12 +324,12 @@ class TrackedResource(Resource): :vartype id: str :ivar name: Resource name. :vartype name: str - :param location: Resource location. - :type location: str + :ivar location: Resource location. + :vartype location: str :ivar type: Resource type. :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -309,6 +353,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(TrackedResource, self).__init__(location=location, **kwargs) self.tags = tags @@ -322,30 +372,30 @@ class NamespaceResource(TrackedResource): :vartype id: str :ivar name: Resource name. :vartype name: str - :param location: Resource location. - :type location: str + :ivar location: Resource location. + :vartype location: str :ivar type: Resource type. :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param sku: SKU of the namespace. - :type sku: ~azure.mgmt.servicebus.v2015_08_01.models.Sku + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar sku: SKU of the namespace. + :vartype sku: ~azure.mgmt.servicebus.v2015_08_01.models.Sku :ivar provisioning_state: Provisioning state of the namespace. :vartype provisioning_state: str - :param status: State of the namespace. Possible values include: "Unknown", "Creating", + :ivar status: State of the namespace. Possible values include: "Unknown", "Creating", "Created", "Activating", "Enabling", "Active", "Disabling", "Disabled", "SoftDeleting", "SoftDeleted", "Removing", "Removed", "Failed". - :type status: str or ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceState + :vartype status: str or ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceState :ivar created_at: The time the namespace was created. :vartype created_at: ~datetime.datetime :ivar updated_at: The time the namespace was updated. :vartype updated_at: ~datetime.datetime :ivar service_bus_endpoint: Endpoint you can use to perform Service Bus operations. :vartype service_bus_endpoint: str - :param create_acs_namespace: Indicates whether to create an ACS namespace. - :type create_acs_namespace: bool - :param enabled: Specifies whether this instance is enabled. - :type enabled: bool + :ivar create_acs_namespace: Indicates whether to create an ACS namespace. + :vartype create_acs_namespace: bool + :ivar enabled: Specifies whether this instance is enabled. + :vartype enabled: bool """ _validation = { @@ -385,6 +435,22 @@ def __init__( enabled: Optional[bool] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword sku: SKU of the namespace. + :paramtype sku: ~azure.mgmt.servicebus.v2015_08_01.models.Sku + :keyword status: State of the namespace. Possible values include: "Unknown", "Creating", + "Created", "Activating", "Enabling", "Active", "Disabling", "Disabled", "SoftDeleting", + "SoftDeleted", "Removing", "Removed", "Failed". + :paramtype status: str or ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceState + :keyword create_acs_namespace: Indicates whether to create an ACS namespace. + :paramtype create_acs_namespace: bool + :keyword enabled: Specifies whether this instance is enabled. + :paramtype enabled: bool + """ super(NamespaceResource, self).__init__(location=location, tags=tags, **kwargs) self.sku = sku self.provisioning_state = None @@ -399,10 +465,10 @@ def __init__( class NamespaceUpdateParameters(msrest.serialization.Model): """Parameters supplied to the Patch Namespace operation. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param sku: The sku of the created namespace. - :type sku: ~azure.mgmt.servicebus.v2015_08_01.models.Sku + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar sku: The sku of the created namespace. + :vartype sku: ~azure.mgmt.servicebus.v2015_08_01.models.Sku """ _attribute_map = { @@ -417,6 +483,12 @@ def __init__( sku: Optional["Sku"] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword sku: The sku of the created namespace. + :paramtype sku: ~azure.mgmt.servicebus.v2015_08_01.models.Sku + """ super(NamespaceUpdateParameters, self).__init__(**kwargs) self.tags = tags self.sku = sku @@ -429,8 +501,8 @@ class Operation(msrest.serialization.Model): :ivar name: Operation name: {provider}/{resource}/{operation}. :vartype name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.servicebus.v2015_08_01.models.OperationDisplay + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.servicebus.v2015_08_01.models.OperationDisplay """ _validation = { @@ -448,6 +520,10 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.servicebus.v2015_08_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = None self.display = display @@ -482,6 +558,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = None self.resource = None @@ -514,6 +592,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -526,72 +606,72 @@ class QueueCreateOrUpdateParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Queue name. - :type name: str - :param location: Required. location of the resource. - :type location: str - :param lock_duration: The duration of a peek-lock; that is, the amount of time that the message + :ivar name: Queue name. + :vartype name: str + :ivar location: Required. location of the resource. + :vartype location: str + :ivar lock_duration: The 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: str + :vartype lock_duration: str :ivar accessed_at: Last time a message was sent, or the last time there was a receive request to this queue. :vartype accessed_at: ~datetime.datetime - :param auto_delete_on_idle: the TimeSpan idle interval after which the queue is automatically + :ivar auto_delete_on_idle: the TimeSpan idle interval after which the queue is automatically deleted. The minimum duration is 5 minutes. - :type auto_delete_on_idle: str - :param entity_availability_status: Entity availability status for the queue. Possible values + :vartype auto_delete_on_idle: str + :ivar entity_availability_status: Entity availability status for the queue. Possible values include: "Available", "Limited", "Renaming", "Restoring", "Unknown". - :type entity_availability_status: str or + :vartype entity_availability_status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityAvailabilityStatus :ivar created_at: The exact time the message was created. :vartype created_at: ~datetime.datetime - :param default_message_time_to_live: The default message time to live value. This is the + :ivar default_message_time_to_live: The default message time 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: str - :param duplicate_detection_history_time_window: TimeSpan structure that defines the duration of + :vartype default_message_time_to_live: str + :ivar duplicate_detection_history_time_window: TimeSpan structure that defines the duration of the duplicate detection history. The default value is 10 minutes. - :type duplicate_detection_history_time_window: str - :param enable_batched_operations: A value that indicates whether server-side batched operations + :vartype duplicate_detection_history_time_window: str + :ivar enable_batched_operations: A value that indicates whether server-side batched operations are enabled. - :type enable_batched_operations: bool - :param dead_lettering_on_message_expiration: A value that indicates whether this queue has dead + :vartype enable_batched_operations: bool + :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 enable_express: A value that indicates whether Express Entities are enabled. An express + :vartype dead_lettering_on_message_expiration: bool + :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 enable_partitioning: A value that indicates whether the queue is to be partitioned - across multiple message brokers. - :type enable_partitioning: bool - :param is_anonymous_accessible: A value that indicates whether the message is accessible + :vartype enable_express: bool + :ivar enable_partitioning: A value that indicates whether the queue is to be partitioned across + multiple message brokers. + :vartype enable_partitioning: bool + :ivar is_anonymous_accessible: A value that indicates whether the message is accessible anonymously. - :type is_anonymous_accessible: bool - :param max_delivery_count: The maximum delivery count. A message is automatically deadlettered + :vartype is_anonymous_accessible: bool + :ivar max_delivery_count: The maximum delivery count. A message is automatically deadlettered after this number of deliveries. - :type max_delivery_count: int - :param max_size_in_megabytes: The maximum size of the queue in megabytes, which is the size of + :vartype max_delivery_count: int + :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 + :vartype max_size_in_megabytes: long :ivar message_count: The number of messages in the queue. :vartype message_count: long :ivar count_details: Message Count Details. :vartype count_details: ~azure.mgmt.servicebus.v2015_08_01.models.MessageCountDetails - :param requires_duplicate_detection: A value indicating if this queue requires duplicate + :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 + :vartype requires_session: bool :ivar size_in_bytes: The size of the queue, in bytes. :vartype size_in_bytes: long - :param status: Enumerates the possible values for the status of a messaging entity. Possible + :ivar status: Enumerates the possible values for the status of a messaging entity. Possible values include: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", "Restoring", "SendDisabled", "Unknown". - :type status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityStatus - :param support_ordering: A value that indicates whether the queue supports ordering. - :type support_ordering: bool + :vartype status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityStatus + :ivar support_ordering: A value that indicates whether the queue supports ordering. + :vartype support_ordering: bool :ivar updated_at: The exact time the message was updated. :vartype updated_at: ~datetime.datetime """ @@ -656,6 +736,63 @@ def __init__( support_ordering: Optional[bool] = None, **kwargs ): + """ + :keyword name: Queue name. + :paramtype name: str + :keyword location: Required. location of the resource. + :paramtype location: str + :keyword lock_duration: The 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: str + :keyword auto_delete_on_idle: the TimeSpan idle interval after which the queue is automatically + deleted. The minimum duration is 5 minutes. + :paramtype auto_delete_on_idle: str + :keyword entity_availability_status: Entity availability status for the queue. Possible values + include: "Available", "Limited", "Renaming", "Restoring", "Unknown". + :paramtype entity_availability_status: str or + ~azure.mgmt.servicebus.v2015_08_01.models.EntityAvailabilityStatus + :keyword default_message_time_to_live: The default message time 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: str + :keyword duplicate_detection_history_time_window: TimeSpan structure that defines the duration + of the duplicate detection history. The default value is 10 minutes. + :paramtype duplicate_detection_history_time_window: str + :keyword enable_batched_operations: A value that indicates whether server-side batched + operations are enabled. + :paramtype enable_batched_operations: bool + :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 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 enable_partitioning: A value that indicates whether the queue is to be partitioned + across multiple message brokers. + :paramtype enable_partitioning: bool + :keyword is_anonymous_accessible: A value that indicates whether the message is accessible + anonymously. + :paramtype is_anonymous_accessible: bool + :keyword max_delivery_count: The maximum delivery count. A message is automatically + deadlettered after this number of deliveries. + :paramtype max_delivery_count: int + :keyword max_size_in_megabytes: The maximum size of the queue in megabytes, which is the size + of memory allocated for the queue. + :paramtype max_size_in_megabytes: long + :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 status: Enumerates the possible values for the status of a messaging entity. Possible + values include: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", + "Restoring", "SendDisabled", "Unknown". + :paramtype status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityStatus + :keyword support_ordering: A value that indicates whether the queue supports ordering. + :paramtype support_ordering: bool + """ super(QueueCreateOrUpdateParameters, self).__init__(**kwargs) self.name = name self.location = location @@ -686,11 +823,11 @@ def __init__( class QueueListResult(msrest.serialization.Model): """The response to the List Queues operation. - :param value: Result of the List Queues operation. - :type value: list[~azure.mgmt.servicebus.v2015_08_01.models.QueueResource] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list + :ivar value: Result of the List Queues operation. + :vartype value: list[~azure.mgmt.servicebus.v2015_08_01.models.QueueResource] + :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of queues. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -705,6 +842,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of the List Queues operation. + :paramtype value: list[~azure.mgmt.servicebus.v2015_08_01.models.QueueResource] + :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete + list of queues. + :paramtype next_link: str + """ super(QueueListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -719,72 +863,72 @@ class QueueResource(Resource): :vartype id: str :ivar name: Resource name. :vartype name: str - :param location: Resource location. - :type location: str + :ivar location: Resource location. + :vartype location: str :ivar type: Resource type. :vartype type: str - :param lock_duration: The duration of a peek-lock; that is, the amount of time that the message + :ivar lock_duration: The 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: str + :vartype lock_duration: str :ivar accessed_at: Last time a message was sent, or the last time there was a receive request to this queue. :vartype accessed_at: ~datetime.datetime - :param auto_delete_on_idle: the TimeSpan idle interval after which the queue is automatically + :ivar auto_delete_on_idle: the TimeSpan idle interval after which the queue is automatically deleted. The minimum duration is 5 minutes. - :type auto_delete_on_idle: str - :param entity_availability_status: Entity availability status for the queue. Possible values + :vartype auto_delete_on_idle: str + :ivar entity_availability_status: Entity availability status for the queue. Possible values include: "Available", "Limited", "Renaming", "Restoring", "Unknown". - :type entity_availability_status: str or + :vartype entity_availability_status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityAvailabilityStatus :ivar created_at: The exact time the message was created. :vartype created_at: ~datetime.datetime - :param default_message_time_to_live: The default message time to live value. This is the + :ivar default_message_time_to_live: The default message time 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: str - :param duplicate_detection_history_time_window: TimeSpan structure that defines the duration of + :vartype default_message_time_to_live: str + :ivar duplicate_detection_history_time_window: TimeSpan structure that defines the duration of the duplicate detection history. The default value is 10 minutes. - :type duplicate_detection_history_time_window: str - :param enable_batched_operations: A value that indicates whether server-side batched operations + :vartype duplicate_detection_history_time_window: str + :ivar enable_batched_operations: A value that indicates whether server-side batched operations are enabled. - :type enable_batched_operations: bool - :param dead_lettering_on_message_expiration: A value that indicates whether this queue has dead + :vartype enable_batched_operations: bool + :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 enable_express: A value that indicates whether Express Entities are enabled. An express + :vartype dead_lettering_on_message_expiration: bool + :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 enable_partitioning: A value that indicates whether the queue is to be partitioned - across multiple message brokers. - :type enable_partitioning: bool - :param is_anonymous_accessible: A value that indicates whether the message is accessible + :vartype enable_express: bool + :ivar enable_partitioning: A value that indicates whether the queue is to be partitioned across + multiple message brokers. + :vartype enable_partitioning: bool + :ivar is_anonymous_accessible: A value that indicates whether the message is accessible anonymously. - :type is_anonymous_accessible: bool - :param max_delivery_count: The maximum delivery count. A message is automatically deadlettered + :vartype is_anonymous_accessible: bool + :ivar max_delivery_count: The maximum delivery count. A message is automatically deadlettered after this number of deliveries. - :type max_delivery_count: int - :param max_size_in_megabytes: The maximum size of the queue in megabytes, which is the size of + :vartype max_delivery_count: int + :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 + :vartype max_size_in_megabytes: long :ivar message_count: The number of messages in the queue. :vartype message_count: long :ivar count_details: Message Count Details. :vartype count_details: ~azure.mgmt.servicebus.v2015_08_01.models.MessageCountDetails - :param requires_duplicate_detection: A value indicating if this queue requires duplicate + :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 + :vartype requires_session: bool :ivar size_in_bytes: The size of the queue, in bytes. :vartype size_in_bytes: long - :param status: Enumerates the possible values for the status of a messaging entity. Possible + :ivar status: Enumerates the possible values for the status of a messaging entity. Possible values include: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", "Restoring", "SendDisabled", "Unknown". - :type status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityStatus - :param support_ordering: A value that indicates whether the queue supports ordering. - :type support_ordering: bool + :vartype status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityStatus + :ivar support_ordering: A value that indicates whether the queue supports ordering. + :vartype support_ordering: bool :ivar updated_at: The exact time the message was updated. :vartype updated_at: ~datetime.datetime """ @@ -852,6 +996,61 @@ def __init__( support_ordering: Optional[bool] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword lock_duration: The 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: str + :keyword auto_delete_on_idle: the TimeSpan idle interval after which the queue is automatically + deleted. The minimum duration is 5 minutes. + :paramtype auto_delete_on_idle: str + :keyword entity_availability_status: Entity availability status for the queue. Possible values + include: "Available", "Limited", "Renaming", "Restoring", "Unknown". + :paramtype entity_availability_status: str or + ~azure.mgmt.servicebus.v2015_08_01.models.EntityAvailabilityStatus + :keyword default_message_time_to_live: The default message time 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: str + :keyword duplicate_detection_history_time_window: TimeSpan structure that defines the duration + of the duplicate detection history. The default value is 10 minutes. + :paramtype duplicate_detection_history_time_window: str + :keyword enable_batched_operations: A value that indicates whether server-side batched + operations are enabled. + :paramtype enable_batched_operations: bool + :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 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 enable_partitioning: A value that indicates whether the queue is to be partitioned + across multiple message brokers. + :paramtype enable_partitioning: bool + :keyword is_anonymous_accessible: A value that indicates whether the message is accessible + anonymously. + :paramtype is_anonymous_accessible: bool + :keyword max_delivery_count: The maximum delivery count. A message is automatically + deadlettered after this number of deliveries. + :paramtype max_delivery_count: int + :keyword max_size_in_megabytes: The maximum size of the queue in megabytes, which is the size + of memory allocated for the queue. + :paramtype max_size_in_megabytes: long + :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 status: Enumerates the possible values for the status of a messaging entity. Possible + values include: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", + "Restoring", "SendDisabled", "Unknown". + :paramtype status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityStatus + :keyword support_ordering: A value that indicates whether the queue supports ordering. + :paramtype support_ordering: bool + """ super(QueueResource, self).__init__(location=location, **kwargs) self.lock_duration = lock_duration self.accessed_at = None @@ -880,9 +1079,9 @@ def __init__( class RegenerateKeysParameters(msrest.serialization.Model): """Parameters supplied to the Regenerate Authorization Rule operation. - :param policykey: Key that needs to be regenerated. Possible values include: "PrimaryKey", + :ivar policykey: Key that needs to be regenerated. Possible values include: "PrimaryKey", "SecondaryKey". - :type policykey: str or ~azure.mgmt.servicebus.v2015_08_01.models.Policykey + :vartype policykey: str or ~azure.mgmt.servicebus.v2015_08_01.models.Policykey """ _attribute_map = { @@ -895,6 +1094,11 @@ def __init__( policykey: Optional[Union[str, "Policykey"]] = None, **kwargs ): + """ + :keyword policykey: Key that needs to be regenerated. Possible values include: "PrimaryKey", + "SecondaryKey". + :paramtype policykey: str or ~azure.mgmt.servicebus.v2015_08_01.models.Policykey + """ super(RegenerateKeysParameters, self).__init__(**kwargs) self.policykey = policykey @@ -902,20 +1106,20 @@ def __init__( class ResourceListKeys(msrest.serialization.Model): """Namespace/ServiceBus Connection String. - :param primary_connection_string: Primary connection string of the created namespace + :ivar primary_connection_string: Primary connection string of the created namespace authorization rule. - :type primary_connection_string: str - :param secondary_connection_string: Secondary connection string of the created namespace + :vartype primary_connection_string: str + :ivar secondary_connection_string: Secondary connection string of the created namespace authorization rule. - :type secondary_connection_string: str - :param primary_key: A base64-encoded 256-bit primary key for signing and validating the SAS + :vartype secondary_connection_string: str + :ivar primary_key: A base64-encoded 256-bit primary key for signing and validating the SAS token. - :type primary_key: str - :param secondary_key: A base64-encoded 256-bit primary key for signing and validating the SAS + :vartype primary_key: str + :ivar secondary_key: A base64-encoded 256-bit primary key for signing and validating the SAS token. - :type secondary_key: str - :param key_name: A string that describes the authorization rule. - :type key_name: str + :vartype secondary_key: str + :ivar key_name: A string that describes the authorization rule. + :vartype key_name: str """ _attribute_map = { @@ -936,6 +1140,22 @@ def __init__( key_name: Optional[str] = None, **kwargs ): + """ + :keyword primary_connection_string: Primary connection string of the created namespace + authorization rule. + :paramtype primary_connection_string: str + :keyword secondary_connection_string: Secondary connection string of the created namespace + authorization rule. + :paramtype secondary_connection_string: str + :keyword primary_key: A base64-encoded 256-bit primary key for signing and validating the SAS + token. + :paramtype primary_key: str + :keyword secondary_key: A base64-encoded 256-bit primary key for signing and validating the SAS + token. + :paramtype secondary_key: str + :keyword key_name: A string that describes the authorization rule. + :paramtype key_name: str + """ super(ResourceListKeys, self).__init__(**kwargs) self.primary_connection_string = primary_connection_string self.secondary_connection_string = secondary_connection_string @@ -947,12 +1167,12 @@ def __init__( class SharedAccessAuthorizationRuleCreateOrUpdateParameters(msrest.serialization.Model): """Parameters supplied to the Create Or Update Authorization Rules operation. - :param location: data center location. - :type location: str - :param name: Name of the authorization rule. - :type name: str - :param rights: The rights associated with the rule. - :type rights: list[str or ~azure.mgmt.servicebus.v2015_08_01.models.AccessRights] + :ivar location: data center location. + :vartype location: str + :ivar name: Name of the authorization rule. + :vartype name: str + :ivar rights: The rights associated with the rule. + :vartype rights: list[str or ~azure.mgmt.servicebus.v2015_08_01.models.AccessRights] """ _attribute_map = { @@ -969,6 +1189,14 @@ def __init__( rights: Optional[List[Union[str, "AccessRights"]]] = None, **kwargs ): + """ + :keyword location: data center location. + :paramtype location: str + :keyword name: Name of the authorization rule. + :paramtype name: str + :keyword rights: The rights associated with the rule. + :paramtype rights: list[str or ~azure.mgmt.servicebus.v2015_08_01.models.AccessRights] + """ super(SharedAccessAuthorizationRuleCreateOrUpdateParameters, self).__init__(**kwargs) self.location = location self.name = name @@ -978,12 +1206,12 @@ def __init__( class SharedAccessAuthorizationRuleListResult(msrest.serialization.Model): """The response to the List Namespace operation. - :param value: Result of the List Authorization Rules operation. - :type value: + :ivar value: Result of the List Authorization Rules operation. + :vartype value: list[~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list + :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of Authorization Rules. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -998,6 +1226,14 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of the List Authorization Rules operation. + :paramtype value: + list[~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource] + :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete + list of Authorization Rules. + :paramtype next_link: str + """ super(SharedAccessAuthorizationRuleListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1012,12 +1248,12 @@ class SharedAccessAuthorizationRuleResource(Resource): :vartype id: str :ivar name: Resource name. :vartype name: str - :param location: Resource location. - :type location: str + :ivar location: Resource location. + :vartype location: str :ivar type: Resource type. :vartype type: str - :param rights: The rights associated with the rule. - :type rights: list[str or ~azure.mgmt.servicebus.v2015_08_01.models.AccessRights] + :ivar rights: The rights associated with the rule. + :vartype rights: list[str or ~azure.mgmt.servicebus.v2015_08_01.models.AccessRights] """ _validation = { @@ -1041,6 +1277,12 @@ def __init__( rights: Optional[List[Union[str, "AccessRights"]]] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword rights: The rights associated with the rule. + :paramtype rights: list[str or ~azure.mgmt.servicebus.v2015_08_01.models.AccessRights] + """ super(SharedAccessAuthorizationRuleResource, self).__init__(location=location, **kwargs) self.rights = rights @@ -1050,13 +1292,13 @@ class Sku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Name of this SKU. Possible values include: "Basic", "Standard", "Premium". - :type name: str or ~azure.mgmt.servicebus.v2015_08_01.models.SkuName - :param tier: Required. The billing tier of this particular SKU. Possible values include: + :ivar name: Name of this SKU. Possible values include: "Basic", "Standard", "Premium". + :vartype name: str or ~azure.mgmt.servicebus.v2015_08_01.models.SkuName + :ivar tier: Required. The billing tier of this particular SKU. Possible values include: "Basic", "Standard", "Premium". - :type tier: str or ~azure.mgmt.servicebus.v2015_08_01.models.SkuTier - :param capacity: The specified messaging units for the tier. - :type capacity: int + :vartype tier: str or ~azure.mgmt.servicebus.v2015_08_01.models.SkuTier + :ivar capacity: The specified messaging units for the tier. + :vartype capacity: int """ _validation = { @@ -1077,6 +1319,15 @@ def __init__( capacity: Optional[int] = None, **kwargs ): + """ + :keyword name: Name of this SKU. Possible values include: "Basic", "Standard", "Premium". + :paramtype name: str or ~azure.mgmt.servicebus.v2015_08_01.models.SkuName + :keyword tier: Required. The billing tier of this particular SKU. Possible values include: + "Basic", "Standard", "Premium". + :paramtype tier: str or ~azure.mgmt.servicebus.v2015_08_01.models.SkuTier + :keyword capacity: The specified messaging units for the tier. + :paramtype capacity: int + """ super(Sku, self).__init__(**kwargs) self.name = name self.tier = tier @@ -1090,50 +1341,50 @@ class SubscriptionCreateOrUpdateParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: Required. Subscription data center location. - :type location: str - :param type: Resource manager type of the resource. - :type type: str + :ivar location: Required. Subscription data center location. + :vartype location: str + :ivar type: Resource manager type of the resource. + :vartype type: str :ivar accessed_at: Last time there was a receive request to this subscription. :vartype accessed_at: ~datetime.datetime - :param auto_delete_on_idle: TimeSpan idle interval after which the topic is automatically + :ivar auto_delete_on_idle: TimeSpan idle interval after which the topic is automatically deleted. The minimum duration is 5 minutes. - :type auto_delete_on_idle: str + :vartype auto_delete_on_idle: str :ivar count_details: Message Count Details. :vartype count_details: ~azure.mgmt.servicebus.v2015_08_01.models.MessageCountDetails :ivar created_at: Exact time the message was created. :vartype created_at: ~datetime.datetime - :param default_message_time_to_live: Default message time to live value. This is the duration + :ivar default_message_time_to_live: Default message time 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: str - :param dead_lettering_on_filter_evaluation_exceptions: Value that indicates whether a + :vartype default_message_time_to_live: str + :ivar dead_lettering_on_filter_evaluation_exceptions: Value that indicates whether a subscription has dead letter support on filter evaluation exceptions. - :type dead_lettering_on_filter_evaluation_exceptions: bool - :param dead_lettering_on_message_expiration: Value that indicates whether a subscription has + :vartype dead_lettering_on_filter_evaluation_exceptions: bool + :ivar dead_lettering_on_message_expiration: Value that indicates whether a subscription has dead letter support when a message expires. - :type dead_lettering_on_message_expiration: bool - :param enable_batched_operations: Value that indicates whether server-side batched operations + :vartype dead_lettering_on_message_expiration: bool + :ivar enable_batched_operations: Value that indicates whether server-side batched operations are enabled. - :type enable_batched_operations: bool - :param entity_availability_status: Entity availability status for the topic. Possible values + :vartype enable_batched_operations: bool + :ivar entity_availability_status: Entity availability status for the topic. Possible values include: "Available", "Limited", "Renaming", "Restoring", "Unknown". - :type entity_availability_status: str or + :vartype entity_availability_status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityAvailabilityStatus - :param is_read_only: Value that indicates whether the entity description is read-only. - :type is_read_only: bool - :param lock_duration: The lock duration time span for the subscription. - :type lock_duration: str - :param max_delivery_count: Number of maximum deliveries. - :type max_delivery_count: int + :ivar is_read_only: Value that indicates whether the entity description is read-only. + :vartype is_read_only: bool + :ivar lock_duration: The lock duration time span for the subscription. + :vartype lock_duration: str + :ivar max_delivery_count: Number of maximum deliveries. + :vartype max_delivery_count: int :ivar message_count: Number of messages. :vartype message_count: long - :param requires_session: Value indicating if a subscription supports the concept of sessions. - :type requires_session: bool - :param status: Enumerates the possible values for the status of a messaging entity. Possible + :ivar requires_session: Value indicating if a subscription supports the concept of sessions. + :vartype requires_session: bool + :ivar status: Enumerates the possible values for the status of a messaging entity. Possible values include: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", "Restoring", "SendDisabled", "Unknown". - :type status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityStatus + :vartype status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityStatus :ivar updated_at: The exact time the message was updated. :vartype updated_at: ~datetime.datetime """ @@ -1186,6 +1437,44 @@ def __init__( status: Optional[Union[str, "EntityStatus"]] = None, **kwargs ): + """ + :keyword location: Required. Subscription data center location. + :paramtype location: str + :keyword type: Resource manager type of the resource. + :paramtype type: str + :keyword auto_delete_on_idle: TimeSpan idle interval after which the topic is automatically + deleted. The minimum duration is 5 minutes. + :paramtype auto_delete_on_idle: str + :keyword default_message_time_to_live: Default message time 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: str + :keyword dead_lettering_on_filter_evaluation_exceptions: Value that indicates whether a + subscription has dead letter support on filter evaluation exceptions. + :paramtype dead_lettering_on_filter_evaluation_exceptions: bool + :keyword dead_lettering_on_message_expiration: Value that indicates whether a subscription has + dead letter support when a message expires. + :paramtype dead_lettering_on_message_expiration: bool + :keyword enable_batched_operations: Value that indicates whether server-side batched operations + are enabled. + :paramtype enable_batched_operations: bool + :keyword entity_availability_status: Entity availability status for the topic. Possible values + include: "Available", "Limited", "Renaming", "Restoring", "Unknown". + :paramtype entity_availability_status: str or + ~azure.mgmt.servicebus.v2015_08_01.models.EntityAvailabilityStatus + :keyword is_read_only: Value that indicates whether the entity description is read-only. + :paramtype is_read_only: bool + :keyword lock_duration: The lock duration time span for the subscription. + :paramtype lock_duration: str + :keyword max_delivery_count: Number of maximum deliveries. + :paramtype max_delivery_count: int + :keyword requires_session: Value indicating if a subscription supports the concept of sessions. + :paramtype requires_session: bool + :keyword status: Enumerates the possible values for the status of a messaging entity. Possible + values include: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", + "Restoring", "SendDisabled", "Unknown". + :paramtype status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityStatus + """ super(SubscriptionCreateOrUpdateParameters, self).__init__(**kwargs) self.location = location self.type = type @@ -1210,11 +1499,11 @@ def __init__( class SubscriptionListResult(msrest.serialization.Model): """The response to the List Subscriptions operation. - :param value: Result of the List Subscriptions operation. - :type value: list[~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionResource] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list + :ivar value: Result of the List Subscriptions operation. + :vartype value: list[~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionResource] + :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of subscriptions. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -1229,6 +1518,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of the List Subscriptions operation. + :paramtype value: list[~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionResource] + :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete + list of subscriptions. + :paramtype next_link: str + """ super(SubscriptionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1243,50 +1539,50 @@ class SubscriptionResource(Resource): :vartype id: str :ivar name: Resource name. :vartype name: str - :param location: Resource location. - :type location: str + :ivar location: Resource location. + :vartype location: str :ivar type: Resource type. :vartype type: str :ivar accessed_at: Last time there was a receive request to this subscription. :vartype accessed_at: ~datetime.datetime - :param auto_delete_on_idle: TimeSpan idle interval after which the topic is automatically + :ivar auto_delete_on_idle: TimeSpan idle interval after which the topic is automatically deleted. The minimum duration is 5 minutes. - :type auto_delete_on_idle: str + :vartype auto_delete_on_idle: str :ivar count_details: Message Count Details. :vartype count_details: ~azure.mgmt.servicebus.v2015_08_01.models.MessageCountDetails :ivar created_at: Exact time the message was created. :vartype created_at: ~datetime.datetime - :param default_message_time_to_live: Default message time to live value. This is the duration + :ivar default_message_time_to_live: Default message time 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: str - :param dead_lettering_on_filter_evaluation_exceptions: Value that indicates whether a + :vartype default_message_time_to_live: str + :ivar dead_lettering_on_filter_evaluation_exceptions: Value that indicates whether a subscription has dead letter support on filter evaluation exceptions. - :type dead_lettering_on_filter_evaluation_exceptions: bool - :param dead_lettering_on_message_expiration: Value that indicates whether a subscription has + :vartype dead_lettering_on_filter_evaluation_exceptions: bool + :ivar dead_lettering_on_message_expiration: Value that indicates whether a subscription has dead letter support when a message expires. - :type dead_lettering_on_message_expiration: bool - :param enable_batched_operations: Value that indicates whether server-side batched operations + :vartype dead_lettering_on_message_expiration: bool + :ivar enable_batched_operations: Value that indicates whether server-side batched operations are enabled. - :type enable_batched_operations: bool - :param entity_availability_status: Entity availability status for the topic. Possible values + :vartype enable_batched_operations: bool + :ivar entity_availability_status: Entity availability status for the topic. Possible values include: "Available", "Limited", "Renaming", "Restoring", "Unknown". - :type entity_availability_status: str or + :vartype entity_availability_status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityAvailabilityStatus - :param is_read_only: Value that indicates whether the entity description is read-only. - :type is_read_only: bool - :param lock_duration: The lock duration time span for the subscription. - :type lock_duration: str - :param max_delivery_count: Number of maximum deliveries. - :type max_delivery_count: int + :ivar is_read_only: Value that indicates whether the entity description is read-only. + :vartype is_read_only: bool + :ivar lock_duration: The lock duration time span for the subscription. + :vartype lock_duration: str + :ivar max_delivery_count: Number of maximum deliveries. + :vartype max_delivery_count: int :ivar message_count: Number of messages. :vartype message_count: long - :param requires_session: Value indicating if a subscription supports the concept of sessions. - :type requires_session: bool - :param status: Enumerates the possible values for the status of a messaging entity. Possible + :ivar requires_session: Value indicating if a subscription supports the concept of sessions. + :vartype requires_session: bool + :ivar status: Enumerates the possible values for the status of a messaging entity. Possible values include: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", "Restoring", "SendDisabled", "Unknown". - :type status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityStatus + :vartype status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityStatus :ivar updated_at: The exact time the message was updated. :vartype updated_at: ~datetime.datetime """ @@ -1342,6 +1638,42 @@ def __init__( status: Optional[Union[str, "EntityStatus"]] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword auto_delete_on_idle: TimeSpan idle interval after which the topic is automatically + deleted. The minimum duration is 5 minutes. + :paramtype auto_delete_on_idle: str + :keyword default_message_time_to_live: Default message time 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: str + :keyword dead_lettering_on_filter_evaluation_exceptions: Value that indicates whether a + subscription has dead letter support on filter evaluation exceptions. + :paramtype dead_lettering_on_filter_evaluation_exceptions: bool + :keyword dead_lettering_on_message_expiration: Value that indicates whether a subscription has + dead letter support when a message expires. + :paramtype dead_lettering_on_message_expiration: bool + :keyword enable_batched_operations: Value that indicates whether server-side batched operations + are enabled. + :paramtype enable_batched_operations: bool + :keyword entity_availability_status: Entity availability status for the topic. Possible values + include: "Available", "Limited", "Renaming", "Restoring", "Unknown". + :paramtype entity_availability_status: str or + ~azure.mgmt.servicebus.v2015_08_01.models.EntityAvailabilityStatus + :keyword is_read_only: Value that indicates whether the entity description is read-only. + :paramtype is_read_only: bool + :keyword lock_duration: The lock duration time span for the subscription. + :paramtype lock_duration: str + :keyword max_delivery_count: Number of maximum deliveries. + :paramtype max_delivery_count: int + :keyword requires_session: Value indicating if a subscription supports the concept of sessions. + :paramtype requires_session: bool + :keyword status: Enumerates the possible values for the status of a messaging entity. Possible + values include: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", + "Restoring", "SendDisabled", "Unknown". + :paramtype status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityStatus + """ super(SubscriptionResource, self).__init__(location=location, **kwargs) self.accessed_at = None self.auto_delete_on_idle = auto_delete_on_idle @@ -1368,63 +1700,63 @@ class TopicCreateOrUpdateParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Topic name. - :type name: str - :param location: Required. Location of the resource. - :type location: str + :ivar name: Topic name. + :vartype name: str + :ivar location: Required. Location of the resource. + :vartype location: str :ivar accessed_at: Last time the message was sent, or a request was received, for this topic. :vartype accessed_at: ~datetime.datetime - :param auto_delete_on_idle: TimeSpan idle interval after which the topic is automatically + :ivar auto_delete_on_idle: TimeSpan idle interval after which the topic is automatically deleted. The minimum duration is 5 minutes. - :type auto_delete_on_idle: str - :param entity_availability_status: Entity availability status for the topic. Possible values + :vartype auto_delete_on_idle: str + :ivar entity_availability_status: Entity availability status for the topic. Possible values include: "Available", "Limited", "Renaming", "Restoring", "Unknown". - :type entity_availability_status: str or + :vartype entity_availability_status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityAvailabilityStatus :ivar created_at: Exact time the message was created. :vartype created_at: ~datetime.datetime :ivar count_details: Message Count Details. :vartype count_details: ~azure.mgmt.servicebus.v2015_08_01.models.MessageCountDetails - :param default_message_time_to_live: Default message time to live value. This is the duration + :ivar default_message_time_to_live: Default message time 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: str - :param duplicate_detection_history_time_window: TimeSpan structure that defines the duration of + :vartype default_message_time_to_live: str + :ivar duplicate_detection_history_time_window: TimeSpan structure that defines the duration of the duplicate detection history. The default value is 10 minutes. - :type duplicate_detection_history_time_window: str - :param enable_batched_operations: Value that indicates whether server-side batched operations + :vartype duplicate_detection_history_time_window: str + :ivar enable_batched_operations: Value that indicates whether server-side batched operations are enabled. - :type enable_batched_operations: bool - :param enable_express: Value that indicates whether Express Entities are enabled. An express + :vartype enable_batched_operations: bool + :ivar enable_express: 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 enable_partitioning: Value that indicates whether the topic to be partitioned across + :vartype enable_express: bool + :ivar enable_partitioning: Value that indicates whether the topic to be partitioned across multiple message brokers is enabled. - :type enable_partitioning: bool - :param filtering_messages_before_publishing: Whether messages should be filtered before + :vartype enable_partitioning: bool + :ivar filtering_messages_before_publishing: Whether messages should be filtered before publishing. - :type filtering_messages_before_publishing: bool - :param is_anonymous_accessible: Value that indicates whether the message is accessible + :vartype filtering_messages_before_publishing: bool + :ivar is_anonymous_accessible: Value that indicates whether the message is accessible anonymously. - :type is_anonymous_accessible: bool - :param is_express: - :type is_express: bool - :param max_size_in_megabytes: Maximum size of the topic in megabytes, which is the size of the + :vartype is_anonymous_accessible: bool + :ivar is_express: + :vartype is_express: bool + :ivar max_size_in_megabytes: Maximum size of the topic in megabytes, which is the size of the memory allocated for the topic. - :type max_size_in_megabytes: long - :param requires_duplicate_detection: Value indicating if this topic requires duplicate + :vartype max_size_in_megabytes: long + :ivar requires_duplicate_detection: Value indicating if this topic requires duplicate detection. - :type requires_duplicate_detection: bool + :vartype requires_duplicate_detection: bool :ivar size_in_bytes: Size of the topic, in bytes. :vartype size_in_bytes: long - :param status: Enumerates the possible values for the status of a messaging entity. Possible + :ivar status: Enumerates the possible values for the status of a messaging entity. Possible values include: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", "Restoring", "SendDisabled", "Unknown". - :type status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityStatus + :vartype status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityStatus :ivar subscription_count: Number of subscriptions. :vartype subscription_count: int - :param support_ordering: Value that indicates whether the topic supports ordering. - :type support_ordering: bool + :ivar support_ordering: Value that indicates whether the topic supports ordering. + :vartype support_ordering: bool :ivar updated_at: The exact time the message was updated. :vartype updated_at: ~datetime.datetime """ @@ -1485,6 +1817,55 @@ def __init__( support_ordering: Optional[bool] = None, **kwargs ): + """ + :keyword name: Topic name. + :paramtype name: str + :keyword location: Required. Location of the resource. + :paramtype location: str + :keyword auto_delete_on_idle: TimeSpan idle interval after which the topic is automatically + deleted. The minimum duration is 5 minutes. + :paramtype auto_delete_on_idle: str + :keyword entity_availability_status: Entity availability status for the topic. Possible values + include: "Available", "Limited", "Renaming", "Restoring", "Unknown". + :paramtype entity_availability_status: str or + ~azure.mgmt.servicebus.v2015_08_01.models.EntityAvailabilityStatus + :keyword default_message_time_to_live: Default message time 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: str + :keyword duplicate_detection_history_time_window: TimeSpan structure that defines the duration + of the duplicate detection history. The default value is 10 minutes. + :paramtype duplicate_detection_history_time_window: str + :keyword enable_batched_operations: Value that indicates whether server-side batched operations + are enabled. + :paramtype enable_batched_operations: bool + :keyword enable_express: 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 enable_partitioning: Value that indicates whether the topic to be partitioned across + multiple message brokers is enabled. + :paramtype enable_partitioning: bool + :keyword filtering_messages_before_publishing: Whether messages should be filtered before + publishing. + :paramtype filtering_messages_before_publishing: bool + :keyword is_anonymous_accessible: Value that indicates whether the message is accessible + anonymously. + :paramtype is_anonymous_accessible: bool + :keyword is_express: + :paramtype is_express: bool + :keyword max_size_in_megabytes: Maximum size of the topic in megabytes, which is the size of + the memory allocated for the topic. + :paramtype max_size_in_megabytes: long + :keyword requires_duplicate_detection: Value indicating if this topic requires duplicate + detection. + :paramtype requires_duplicate_detection: bool + :keyword status: Enumerates the possible values for the status of a messaging entity. Possible + values include: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", + "Restoring", "SendDisabled", "Unknown". + :paramtype status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityStatus + :keyword support_ordering: Value that indicates whether the topic supports ordering. + :paramtype support_ordering: bool + """ super(TopicCreateOrUpdateParameters, self).__init__(**kwargs) self.name = name self.location = location @@ -1513,11 +1894,11 @@ def __init__( class TopicListResult(msrest.serialization.Model): """The response to the List Topics operation. - :param value: Result of the List Topics operation. - :type value: list[~azure.mgmt.servicebus.v2015_08_01.models.TopicResource] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list + :ivar value: Result of the List Topics operation. + :vartype value: list[~azure.mgmt.servicebus.v2015_08_01.models.TopicResource] + :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of topics. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -1532,6 +1913,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of the List Topics operation. + :paramtype value: list[~azure.mgmt.servicebus.v2015_08_01.models.TopicResource] + :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete + list of topics. + :paramtype next_link: str + """ super(TopicListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1546,63 +1934,63 @@ class TopicResource(Resource): :vartype id: str :ivar name: Resource name. :vartype name: str - :param location: Resource location. - :type location: str + :ivar location: Resource location. + :vartype location: str :ivar type: Resource type. :vartype type: str :ivar accessed_at: Last time the message was sent, or a request was received, for this topic. :vartype accessed_at: ~datetime.datetime - :param auto_delete_on_idle: TimeSpan idle interval after which the topic is automatically + :ivar auto_delete_on_idle: TimeSpan idle interval after which the topic is automatically deleted. The minimum duration is 5 minutes. - :type auto_delete_on_idle: str - :param entity_availability_status: Entity availability status for the topic. Possible values + :vartype auto_delete_on_idle: str + :ivar entity_availability_status: Entity availability status for the topic. Possible values include: "Available", "Limited", "Renaming", "Restoring", "Unknown". - :type entity_availability_status: str or + :vartype entity_availability_status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityAvailabilityStatus :ivar created_at: Exact time the message was created. :vartype created_at: ~datetime.datetime :ivar count_details: Message Count Details. :vartype count_details: ~azure.mgmt.servicebus.v2015_08_01.models.MessageCountDetails - :param default_message_time_to_live: Default message time to live value. This is the duration + :ivar default_message_time_to_live: Default message time 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: str - :param duplicate_detection_history_time_window: TimeSpan structure that defines the duration of + :vartype default_message_time_to_live: str + :ivar duplicate_detection_history_time_window: TimeSpan structure that defines the duration of the duplicate detection history. The default value is 10 minutes. - :type duplicate_detection_history_time_window: str - :param enable_batched_operations: Value that indicates whether server-side batched operations + :vartype duplicate_detection_history_time_window: str + :ivar enable_batched_operations: Value that indicates whether server-side batched operations are enabled. - :type enable_batched_operations: bool - :param enable_express: Value that indicates whether Express Entities are enabled. An express + :vartype enable_batched_operations: bool + :ivar enable_express: 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 enable_partitioning: Value that indicates whether the topic to be partitioned across + :vartype enable_express: bool + :ivar enable_partitioning: Value that indicates whether the topic to be partitioned across multiple message brokers is enabled. - :type enable_partitioning: bool - :param filtering_messages_before_publishing: Whether messages should be filtered before + :vartype enable_partitioning: bool + :ivar filtering_messages_before_publishing: Whether messages should be filtered before publishing. - :type filtering_messages_before_publishing: bool - :param is_anonymous_accessible: Value that indicates whether the message is accessible + :vartype filtering_messages_before_publishing: bool + :ivar is_anonymous_accessible: Value that indicates whether the message is accessible anonymously. - :type is_anonymous_accessible: bool - :param is_express: - :type is_express: bool - :param max_size_in_megabytes: Maximum size of the topic in megabytes, which is the size of the + :vartype is_anonymous_accessible: bool + :ivar is_express: + :vartype is_express: bool + :ivar max_size_in_megabytes: Maximum size of the topic in megabytes, which is the size of the memory allocated for the topic. - :type max_size_in_megabytes: long - :param requires_duplicate_detection: Value indicating if this topic requires duplicate + :vartype max_size_in_megabytes: long + :ivar requires_duplicate_detection: Value indicating if this topic requires duplicate detection. - :type requires_duplicate_detection: bool + :vartype requires_duplicate_detection: bool :ivar size_in_bytes: Size of the topic, in bytes. :vartype size_in_bytes: long - :param status: Enumerates the possible values for the status of a messaging entity. Possible + :ivar status: Enumerates the possible values for the status of a messaging entity. Possible values include: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", "Restoring", "SendDisabled", "Unknown". - :type status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityStatus + :vartype status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityStatus :ivar subscription_count: Number of subscriptions. :vartype subscription_count: int - :param support_ordering: Value that indicates whether the topic supports ordering. - :type support_ordering: bool + :ivar support_ordering: Value that indicates whether the topic supports ordering. + :vartype support_ordering: bool :ivar updated_at: The exact time the message was updated. :vartype updated_at: ~datetime.datetime """ @@ -1666,6 +2054,53 @@ def __init__( support_ordering: Optional[bool] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword auto_delete_on_idle: TimeSpan idle interval after which the topic is automatically + deleted. The minimum duration is 5 minutes. + :paramtype auto_delete_on_idle: str + :keyword entity_availability_status: Entity availability status for the topic. Possible values + include: "Available", "Limited", "Renaming", "Restoring", "Unknown". + :paramtype entity_availability_status: str or + ~azure.mgmt.servicebus.v2015_08_01.models.EntityAvailabilityStatus + :keyword default_message_time_to_live: Default message time 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: str + :keyword duplicate_detection_history_time_window: TimeSpan structure that defines the duration + of the duplicate detection history. The default value is 10 minutes. + :paramtype duplicate_detection_history_time_window: str + :keyword enable_batched_operations: Value that indicates whether server-side batched operations + are enabled. + :paramtype enable_batched_operations: bool + :keyword enable_express: 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 enable_partitioning: Value that indicates whether the topic to be partitioned across + multiple message brokers is enabled. + :paramtype enable_partitioning: bool + :keyword filtering_messages_before_publishing: Whether messages should be filtered before + publishing. + :paramtype filtering_messages_before_publishing: bool + :keyword is_anonymous_accessible: Value that indicates whether the message is accessible + anonymously. + :paramtype is_anonymous_accessible: bool + :keyword is_express: + :paramtype is_express: bool + :keyword max_size_in_megabytes: Maximum size of the topic in megabytes, which is the size of + the memory allocated for the topic. + :paramtype max_size_in_megabytes: long + :keyword requires_duplicate_detection: Value indicating if this topic requires duplicate + detection. + :paramtype requires_duplicate_detection: bool + :keyword status: Enumerates the possible values for the status of a messaging entity. Possible + values include: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", + "Restoring", "SendDisabled", "Unknown". + :paramtype status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityStatus + :keyword support_ordering: Value that indicates whether the topic supports ordering. + :paramtype support_ordering: bool + """ super(TopicResource, self).__init__(location=location, **kwargs) self.accessed_at = None self.auto_delete_on_idle = auto_delete_on_idle diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/models/_service_bus_management_client_enums.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/models/_service_bus_management_client_enums.py index e6b495d5c78a..cf2f6d9c084d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/models/_service_bus_management_client_enums.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/models/_service_bus_management_client_enums.py @@ -6,33 +6,18 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AccessRights(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MANAGE = "Manage" SEND = "Send" LISTEN = "Listen" -class EntityAvailabilityStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class EntityAvailabilityStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Entity availability status. """ @@ -42,7 +27,7 @@ class EntityAvailabilityStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enu RESTORING = "Restoring" UNKNOWN = "Unknown" -class EntityStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class EntityStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Entity status. """ @@ -56,7 +41,7 @@ class EntityStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SEND_DISABLED = "SendDisabled" UNKNOWN = "Unknown" -class NamespaceState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class NamespaceState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """State of the namespace. """ @@ -74,14 +59,14 @@ class NamespaceState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): REMOVED = "Removed" FAILED = "Failed" -class Policykey(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Policykey(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Key that needs to be regenerated. """ PRIMARY_KEY = "PrimaryKey" SECONDARY_KEY = "SecondaryKey" -class SkuName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Name of this SKU. """ @@ -89,7 +74,7 @@ class SkuName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): STANDARD = "Standard" PREMIUM = "Premium" -class SkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The billing tier of this particular SKU. """ @@ -97,7 +82,7 @@ class SkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): STANDARD = "Standard" PREMIUM = "Premium" -class UnavailableReason(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class UnavailableReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Specifies the reason for the unavailability of the service. """ diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_namespaces_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_namespaces_operations.py index c8d403dde987..e0682474fbd5 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_namespaces_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_namespaces_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,25 +6,523 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_check_name_availability_request( + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_authorization_rules_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + **kwargs + ) + + +def build_get_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_keys_request( + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_regenerate_keys_request( + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) class NamespacesOperations(object): """NamespacesOperations operations. @@ -47,12 +546,12 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def check_name_availability( self, - parameters, # type: "_models.CheckNameAvailability" - **kwargs # type: Any - ): - # type: (...) -> "_models.CheckNameAvailabilityResult" + parameters: "_models.CheckNameAvailability", + **kwargs: Any + ) -> "_models.CheckNameAvailabilityResult": """Check the give namespace name availability. :param parameters: Parameters to check availability of the given namespace name. @@ -67,31 +566,27 @@ def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CheckNameAvailability') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'CheckNameAvailability') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -104,53 +599,55 @@ def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability"} # type: ignore + + + @distributed_trace def list_by_subscription( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.NamespaceListResult"] + **kwargs: Any + ) -> Iterable["_models.NamespaceListResult"]: """Gets all the available namespaces within the subscription, irrespective of the resource groups. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either NamespaceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.NamespaceListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.NamespaceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.NamespaceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('NamespaceListResult', pipeline_response) + deserialized = self._deserialize("NamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -159,7 +656,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -168,60 +669,62 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces'} # type: ignore + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces"} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.NamespaceListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.NamespaceListResult"]: """Gets the available namespaces within a resource group. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either NamespaceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.NamespaceListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.NamespaceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.NamespaceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('NamespaceListResult', pipeline_response) + deserialized = self._deserialize("NamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -230,7 +733,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -239,51 +746,47 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces"} # type: ignore def _create_or_update_initial( self, - resource_group_name, # type: str - namespace_name, # type: str - parameters, # type: "_models.NamespaceCreateOrUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.NamespaceResource"] + resource_group_name: str, + namespace_name: str, + parameters: "_models.NamespaceCreateOrUpdateParameters", + **kwargs: Any + ) -> Optional["_models.NamespaceResource"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.NamespaceResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'NamespaceCreateOrUpdateParameters') - 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) + + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'NamespaceCreateOrUpdateParameters') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -301,16 +804,18 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - namespace_name, # type: str - parameters, # type: "_models.NamespaceCreateOrUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.NamespaceResource"] + resource_group_name: str, + namespace_name: str, + parameters: "_models.NamespaceCreateOrUpdateParameters", + **kwargs: Any + ) -> LROPoller["_models.NamespaceResource"]: """Creates or updates a service namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. @@ -322,14 +827,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceCreateOrUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either NamespaceResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2015_08_01.models.NamespaceResource] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either NamespaceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2015_08_01.models.NamespaceResource] + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.NamespaceResource"] lro_delay = kwargs.pop( @@ -342,27 +853,22 @@ def begin_create_or_update( resource_group_name=resource_group_name, namespace_name=namespace_name, parameters=parameters, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('NamespaceResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -372,42 +878,40 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - def _delete_initial( + def _delete_initial( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2015-08-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -417,15 +921,16 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + - def begin_delete( + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes an existing namespace. This operation also removes all associated resources under the namespace. @@ -435,14 +940,17 @@ def begin_delete( :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-08-01") # type: str polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( @@ -454,24 +962,18 @@ def begin_delete( raw_result = self._delete_initial( resource_group_name=resource_group_name, namespace_name=namespace_name, + api_version=api_version, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -481,17 +983,17 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.NamespaceResource" + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> "_models.NamespaceResource": """Gets a description for the specified namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -508,28 +1010,25 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2015-08-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -542,16 +1041,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + + @distributed_trace def update( self, - resource_group_name, # type: str - namespace_name, # type: str - parameters, # type: "_models.NamespaceUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.NamespaceResource"] + resource_group_name: str, + namespace_name: str, + parameters: "_models.NamespaceUpdateParameters", + **kwargs: Any + ) -> Optional["_models.NamespaceResource"]: """Updates a service namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. @@ -571,33 +1072,29 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'NamespaceUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'NamespaceUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -615,15 +1112,17 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + + @distributed_trace def list_authorization_rules( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SharedAccessAuthorizationRuleListResult"] + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> Iterable["_models.SharedAccessAuthorizationRuleListResult"]: """Gets the authorization rules for a namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -631,45 +1130,48 @@ def list_authorization_rules( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleListResult] + :return: An iterator like instance of either SharedAccessAuthorizationRuleListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessAuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SharedAccessAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SharedAccessAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -678,7 +1180,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -687,20 +1193,21 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules"} # type: ignore + @distributed_trace def create_or_update_authorization_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - authorization_rule_name, # type: str - parameters, # type: "_models.SharedAccessAuthorizationRuleCreateOrUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.SharedAccessAuthorizationRuleResource" + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: "_models.SharedAccessAuthorizationRuleCreateOrUpdateParameters", + **kwargs: Any + ) -> "_models.SharedAccessAuthorizationRuleResource": """Creates or updates an authorization rule for a namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -710,7 +1217,8 @@ def create_or_update_authorization_rule( :param authorization_rule_name: The authorization rule name. :type authorization_rule_name: str :param parameters: The shared access authorization rule. - :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters + :type parameters: + ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: SharedAccessAuthorizationRuleResource, or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource @@ -721,34 +1229,30 @@ def create_or_update_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SharedAccessAuthorizationRuleCreateOrUpdateParameters') - 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) + + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SharedAccessAuthorizationRuleCreateOrUpdateParameters') + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -761,16 +1265,18 @@ def create_or_update_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}'} # type: ignore - def delete_authorization_rule( + create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace + def delete_authorization_rule( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> None: """Deletes a namespace authorization rule. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -789,27 +1295,26 @@ def delete_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - - # Construct URL - url = self.delete_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2015-08-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -819,16 +1324,17 @@ def delete_authorization_rule( if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}'} # type: ignore + delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore + + @distributed_trace def get_authorization_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SharedAccessAuthorizationRuleResource" + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.SharedAccessAuthorizationRuleResource": """Gets an authorization rule for a namespace by rule name. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -847,29 +1353,26 @@ def get_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2015-08-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -882,16 +1385,18 @@ def get_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}'} # type: ignore + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace def list_keys( self, - resource_group_name, # type: str - namespace_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ResourceListKeys" + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.ResourceListKeys": """Gets the primary and secondary connection strings for the namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -910,29 +1415,26 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2015-08-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -945,17 +1447,19 @@ def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore + + + @distributed_trace def regenerate_keys( self, - resource_group_name, # type: str - namespace_name, # type: str - authorization_rule_name, # type: str - parameters, # type: "_models.RegenerateKeysParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.ResourceListKeys" + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: "_models.RegenerateKeysParameters", + **kwargs: Any + ) -> "_models.ResourceListKeys": """Regenerates the primary or secondary connection strings for the namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -976,34 +1480,30 @@ def regenerate_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegenerateKeysParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RegenerateKeysParameters') + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1016,4 +1516,6 @@ def regenerate_keys( return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys'} # type: ignore + + regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_operations.py index 5815ac6a0236..c42fdefdeb5d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,50 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.ServiceBus/operations") + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,47 +73,49 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationListResult"] + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: """Lists all of the available ServiceBus REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.OperationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -94,7 +124,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -103,7 +137,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.ServiceBus/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.ServiceBus/operations"} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_queues_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_queues_operations.py index 8d2009db92b9..0fe61bd03daf 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_queues_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_queues_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,465 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_all_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_authorization_rules_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_post_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_delete_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + **kwargs + ) + + +def build_get_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_keys_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_regenerate_keys_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) class QueuesOperations(object): """QueuesOperations operations. @@ -45,13 +488,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_all( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.QueueListResult"] + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> Iterable["_models.QueueListResult"]: """Gets the queues within a namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -63,41 +506,42 @@ def list_all( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.QueueListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.QueueListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_all.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_all_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_all.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_all_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('QueueListResult', pipeline_response) + deserialized = self._deserialize("QueueListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,7 +550,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -115,20 +563,21 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list_all.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues'} # type: ignore + list_all.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues"} # type: ignore + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - parameters, # type: "_models.QueueCreateOrUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.QueueResource" + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: "_models.QueueCreateOrUpdateParameters", + **kwargs: Any + ) -> "_models.QueueResource": """Creates or updates a Service Bus queue. This operation is idempotent. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -149,34 +598,30 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'QueueCreateOrUpdateParameters') - 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) + + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'QueueCreateOrUpdateParameters') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -189,16 +634,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}'} # type: ignore - def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + queue_name: str, + **kwargs: Any + ) -> None: """Deletes a queue from the specified namespace in a resource group. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -217,27 +664,26 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2015-08-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -247,16 +693,17 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.QueueResource" + resource_group_name: str, + namespace_name: str, + queue_name: str, + **kwargs: Any + ) -> "_models.QueueResource": """Returns a description for the specified queue. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -275,29 +722,26 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2015-08-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -310,16 +754,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore + + + @distributed_trace def list_authorization_rules( self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SharedAccessAuthorizationRuleListResult"] + resource_group_name: str, + namespace_name: str, + queue_name: str, + **kwargs: Any + ) -> Iterable["_models.SharedAccessAuthorizationRuleListResult"]: """Gets all authorization rules for a queue. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -329,46 +775,50 @@ def list_authorization_rules( :param queue_name: The queue name. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleListResult] + :return: An iterator like instance of either SharedAccessAuthorizationRuleListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessAuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SharedAccessAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SharedAccessAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -377,7 +827,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -386,21 +840,22 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules"} # type: ignore + @distributed_trace def create_or_update_authorization_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - authorization_rule_name, # type: str - parameters, # type: "_models.SharedAccessAuthorizationRuleCreateOrUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.SharedAccessAuthorizationRuleResource" + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: "_models.SharedAccessAuthorizationRuleCreateOrUpdateParameters", + **kwargs: Any + ) -> "_models.SharedAccessAuthorizationRuleResource": """Creates an authorization rule for a queue. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -412,7 +867,8 @@ def create_or_update_authorization_rule( :param authorization_rule_name: The authorization rule name. :type authorization_rule_name: str :param parameters: The shared access authorization rule. - :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters + :type parameters: + ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: SharedAccessAuthorizationRuleResource, or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource @@ -423,35 +879,31 @@ def create_or_update_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SharedAccessAuthorizationRuleCreateOrUpdateParameters') - 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) + + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SharedAccessAuthorizationRuleCreateOrUpdateParameters') + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -464,17 +916,19 @@ def create_or_update_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}'} # type: ignore + create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace def post_authorization_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SharedAccessAuthorizationRuleResource" + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.SharedAccessAuthorizationRuleResource": """Gets an authorization rule for a queue by rule name. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -495,30 +949,27 @@ def post_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - - # Construct URL - url = self.post_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + + request = build_post_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.post_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -531,17 +982,19 @@ def post_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - post_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}'} # type: ignore - def delete_authorization_rule( + post_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace + def delete_authorization_rule( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> None: """Deletes a queue authorization rule. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -562,28 +1015,27 @@ def delete_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - - # Construct URL - url = self.delete_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -593,17 +1045,18 @@ def delete_authorization_rule( if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}'} # type: ignore + delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + @distributed_trace def get_authorization_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SharedAccessAuthorizationRuleResource" + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.SharedAccessAuthorizationRuleResource": """Gets an authorization rule for a queue by rule name. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -624,30 +1077,27 @@ def get_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -660,17 +1110,19 @@ def get_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}'} # type: ignore + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace def list_keys( self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ResourceListKeys" + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.ResourceListKeys": """Primary and secondary connection strings to the queue. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -691,30 +1143,27 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -727,18 +1176,20 @@ def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore + + + @distributed_trace def regenerate_keys( self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - authorization_rule_name, # type: str - parameters, # type: "_models.RegenerateKeysParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.ResourceListKeys" + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: "_models.RegenerateKeysParameters", + **kwargs: Any + ) -> "_models.ResourceListKeys": """Regenerates the primary or secondary connection strings to the queue. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -761,35 +1212,31 @@ def regenerate_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegenerateKeysParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RegenerateKeysParameters') + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -802,4 +1249,6 @@ def regenerate_keys( return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys'} # type: ignore + + regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_subscriptions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_subscriptions_operations.py index b8ce3a8356e8..7faeb09fafb9 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_subscriptions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_subscriptions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,185 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_all_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', max_length=50, min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', max_length=50, min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', max_length=50, min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class SubscriptionsOperations(object): """SubscriptionsOperations operations. @@ -45,14 +208,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_all( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SubscriptionListResult"] + resource_group_name: str, + namespace_name: str, + topic_name: str, + **kwargs: Any + ) -> Iterable["_models.SubscriptionListResult"]: """List all the subscriptions under a specified topic. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -62,46 +225,50 @@ def list_all( :param topic_name: The topic name. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionListResult] + :return: An iterator like instance of either SubscriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_all.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_all_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_all.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_all_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SubscriptionListResult', pipeline_response) + deserialized = self._deserialize("SubscriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,7 +277,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,21 +290,22 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list_all.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions'} # type: ignore + list_all.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions"} # type: ignore + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - subscription_name, # type: str - parameters, # type: "_models.SubscriptionCreateOrUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.SubscriptionResource" + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: "_models.SubscriptionCreateOrUpdateParameters", + **kwargs: Any + ) -> "_models.SubscriptionResource": """Creates a topic subscription. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -145,7 +317,8 @@ def create_or_update( :param subscription_name: The subscription name. :type subscription_name: str :param parameters: Parameters supplied to create a subscription resource. - :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionCreateOrUpdateParameters + :type parameters: + ~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionCreateOrUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: SubscriptionResource, or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionResource @@ -156,35 +329,31 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SubscriptionCreateOrUpdateParameters') - 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) + + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SubscriptionCreateOrUpdateParameters') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -197,17 +366,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}'} # type: ignore - def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - subscription_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + **kwargs: Any + ) -> None: """Deletes a subscription from the specified topic. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -228,28 +399,27 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -259,17 +429,18 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - subscription_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SubscriptionResource" + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + **kwargs: Any + ) -> "_models.SubscriptionResource": """Returns a subscription description for the specified topic. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -290,30 +461,27 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -326,4 +494,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_topics_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_topics_operations.py index 32b70acb162b..6bc034527b2d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_topics_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_topics_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,465 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_all_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_authorization_rules_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_post_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_delete_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + **kwargs + ) + + +def build_list_keys_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_regenerate_keys_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) class TopicsOperations(object): """TopicsOperations operations. @@ -45,13 +488,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_all( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.TopicListResult"] + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> Iterable["_models.TopicListResult"]: """Gets all the topics in a namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -63,41 +506,42 @@ def list_all( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.TopicListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.TopicListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_all.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_all_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_all.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_all_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TopicListResult', pipeline_response) + deserialized = self._deserialize("TopicListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,7 +550,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -115,20 +563,21 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list_all.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics'} # type: ignore + list_all.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics"} # type: ignore + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - parameters, # type: "_models.TopicCreateOrUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.TopicResource" + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: "_models.TopicCreateOrUpdateParameters", + **kwargs: Any + ) -> "_models.TopicResource": """Creates a topic in the specified namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -149,34 +598,30 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TopicCreateOrUpdateParameters') - 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) + + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TopicCreateOrUpdateParameters') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -189,16 +634,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}'} # type: ignore - def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + topic_name: str, + **kwargs: Any + ) -> None: """Deletes a topic from the specified namespace and resource group. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -217,27 +664,26 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2015-08-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -247,16 +693,17 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.TopicResource" + resource_group_name: str, + namespace_name: str, + topic_name: str, + **kwargs: Any + ) -> "_models.TopicResource": """Returns a description for the specified topic. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -275,29 +722,26 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2015-08-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -310,16 +754,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore + + + @distributed_trace def list_authorization_rules( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SharedAccessAuthorizationRuleListResult"] + resource_group_name: str, + namespace_name: str, + topic_name: str, + **kwargs: Any + ) -> Iterable["_models.SharedAccessAuthorizationRuleListResult"]: """Gets authorization rules for a topic. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -329,46 +775,50 @@ def list_authorization_rules( :param topic_name: The topic name. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleListResult] + :return: An iterator like instance of either SharedAccessAuthorizationRuleListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessAuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SharedAccessAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SharedAccessAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -377,7 +827,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -386,21 +840,22 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules"} # type: ignore + @distributed_trace def create_or_update_authorization_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - authorization_rule_name, # type: str - parameters, # type: "_models.SharedAccessAuthorizationRuleCreateOrUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.SharedAccessAuthorizationRuleResource" + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: "_models.SharedAccessAuthorizationRuleCreateOrUpdateParameters", + **kwargs: Any + ) -> "_models.SharedAccessAuthorizationRuleResource": """Creates an authorization rule for the specified topic. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -412,7 +867,8 @@ def create_or_update_authorization_rule( :param authorization_rule_name: The authorization rule name. :type authorization_rule_name: str :param parameters: The shared access authorization rule. - :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters + :type parameters: + ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: SharedAccessAuthorizationRuleResource, or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource @@ -423,35 +879,31 @@ def create_or_update_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SharedAccessAuthorizationRuleCreateOrUpdateParameters') - 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) + + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SharedAccessAuthorizationRuleCreateOrUpdateParameters') + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -464,17 +916,19 @@ def create_or_update_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}'} # type: ignore + create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace def post_authorization_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SharedAccessAuthorizationRuleResource" + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.SharedAccessAuthorizationRuleResource": """Returns the specified authorization rule. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -495,30 +949,27 @@ def post_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - - # Construct URL - url = self.post_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + + request = build_post_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.post_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -531,17 +982,19 @@ def post_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - post_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}'} # type: ignore + post_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace def get_authorization_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SharedAccessAuthorizationRuleResource" + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.SharedAccessAuthorizationRuleResource": """Returns the specified authorization rule. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -562,30 +1015,27 @@ def get_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -598,17 +1048,19 @@ def get_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}'} # type: ignore - def delete_authorization_rule( + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace + def delete_authorization_rule( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> None: """Deletes a topic authorization rule. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -629,28 +1081,27 @@ def delete_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - - # Construct URL - url = self.delete_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -660,17 +1111,18 @@ def delete_authorization_rule( if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}'} # type: ignore + delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + @distributed_trace def list_keys( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ResourceListKeys" + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.ResourceListKeys": """Gets the primary and secondary connection strings for the topic. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -691,30 +1143,27 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -727,18 +1176,20 @@ def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore + + + @distributed_trace def regenerate_keys( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - authorization_rule_name, # type: str - parameters, # type: "_models.RegenerateKeysParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.ResourceListKeys" + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: "_models.RegenerateKeysParameters", + **kwargs: Any + ) -> "_models.ResourceListKeys": """Regenerates primary or secondary connection strings for the topic. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -761,35 +1212,31 @@ def regenerate_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegenerateKeysParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2015-08-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RegenerateKeysParameters') + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -802,4 +1249,6 @@ def regenerate_keys( return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys'} # type: ignore + + regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/__init__.py index e6ef471ff03a..aa0384448e69 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ServiceBusManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_configuration.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_configuration.py index 19697db15f03..9d9d0c72d087 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_configuration.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_configuration.py @@ -6,22 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -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 @@ -29,26 +27,31 @@ class ServiceBusManagementClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2017-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2017-04-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-servicebus/{}'.format(VERSION)) self._configure(**kwargs) @@ -68,4 +71,4 @@ def _configure( 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) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_metadata.json b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_metadata.json index f5b275a5417b..d03a673a307f 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_metadata.json +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_metadata.json @@ -5,13 +5,13 @@ "name": "ServiceBusManagementClient", "filename": "_service_bus_management_client", "description": "Azure Service Bus client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "namespaces": "NamespacesOperations", diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_service_bus_management_client.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_service_bus_management_client.py index 21dce75ea7b8..258436ca0706 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_service_bus_management_client.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_service_bus_management_client.py @@ -6,34 +6,23 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient -from ._configuration import ServiceBusManagementClientConfiguration -from .operations import NamespacesOperations -from .operations import QueuesOperations -from .operations import TopicsOperations -from .operations import DisasterRecoveryConfigsOperations -from .operations import EventHubsOperations -from .operations import MigrationConfigsOperations -from .operations import Operations -from .operations import PremiumMessagingRegionsOperations -from .operations import RulesOperations -from .operations import RegionsOperations -from .operations import SubscriptionsOperations from . import models +from ._configuration import ServiceBusManagementClientConfiguration +from .operations import DisasterRecoveryConfigsOperations, EventHubsOperations, MigrationConfigsOperations, NamespacesOperations, Operations, PremiumMessagingRegionsOperations, QueuesOperations, RegionsOperations, RulesOperations, SubscriptionsOperations, TopicsOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class ServiceBusManagementClient(object): +class ServiceBusManagementClient: # pylint: disable=too-many-instance-attributes """Azure Service Bus client. :ivar namespaces: NamespacesOperations operations @@ -43,15 +32,18 @@ class ServiceBusManagementClient(object): :ivar topics: TopicsOperations operations :vartype topics: azure.mgmt.servicebus.v2017_04_01.operations.TopicsOperations :ivar disaster_recovery_configs: DisasterRecoveryConfigsOperations operations - :vartype disaster_recovery_configs: azure.mgmt.servicebus.v2017_04_01.operations.DisasterRecoveryConfigsOperations + :vartype disaster_recovery_configs: + azure.mgmt.servicebus.v2017_04_01.operations.DisasterRecoveryConfigsOperations :ivar event_hubs: EventHubsOperations operations :vartype event_hubs: azure.mgmt.servicebus.v2017_04_01.operations.EventHubsOperations :ivar migration_configs: MigrationConfigsOperations operations - :vartype migration_configs: azure.mgmt.servicebus.v2017_04_01.operations.MigrationConfigsOperations + :vartype migration_configs: + azure.mgmt.servicebus.v2017_04_01.operations.MigrationConfigsOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.servicebus.v2017_04_01.operations.Operations :ivar premium_messaging_regions: PremiumMessagingRegionsOperations operations - :vartype premium_messaging_regions: azure.mgmt.servicebus.v2017_04_01.operations.PremiumMessagingRegionsOperations + :vartype premium_messaging_regions: + azure.mgmt.servicebus.v2017_04_01.operations.PremiumMessagingRegionsOperations :ivar rules: RulesOperations operations :vartype rules: azure.mgmt.servicebus.v2017_04_01.operations.RulesOperations :ivar regions: RegionsOperations operations @@ -60,70 +52,70 @@ class ServiceBusManagementClient(object): :vartype subscriptions: azure.mgmt.servicebus.v2017_04_01.operations.SubscriptionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2017-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ServiceBusManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ServiceBusManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - - self.namespaces = NamespacesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.queues = QueuesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.topics = TopicsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.disaster_recovery_configs = DisasterRecoveryConfigsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.event_hubs = EventHubsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.migration_configs = MigrationConfigsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.premium_messaging_regions = PremiumMessagingRegionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.rules = RulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.regions = RegionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + self._serialize.client_side_validation = False + self.namespaces = NamespacesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queues = QueuesOperations(self._client, self._config, self._serialize, self._deserialize) + self.topics = TopicsOperations(self._client, self._config, self._serialize, self._deserialize) + self.disaster_recovery_configs = DisasterRecoveryConfigsOperations(self._client, self._config, self._serialize, self._deserialize) + self.event_hubs = EventHubsOperations(self._client, self._config, self._serialize, self._deserialize) + self.migration_configs = MigrationConfigsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.premium_messaging_regions = PremiumMessagingRegionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.rules = RulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.regions = RegionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations(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. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_vendor.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# 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 azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_version.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_version.py index e7ffc58c0429..e5754a47ce68 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_version.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "7.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/__init__.py index 9016cbc21795..1b5398b4946f 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._service_bus_management_client import ServiceBusManagementClient __all__ = ['ServiceBusManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/_configuration.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/_configuration.py index 1c107051ba50..866336bb0959 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/_configuration.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -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 @@ -27,8 +27,12 @@ class ServiceBusManagementClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2017-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -37,15 +41,17 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2017-04-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-servicebus/{}'.format(VERSION)) self._configure(**kwargs) @@ -64,4 +70,4 @@ def _configure( 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) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/_service_bus_management_client.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/_service_bus_management_client.py index ecfea0af33bb..3b5bedd8159e 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/_service_bus_management_client.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/_service_bus_management_client.py @@ -6,32 +6,23 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient -from ._configuration import ServiceBusManagementClientConfiguration -from .operations import NamespacesOperations -from .operations import QueuesOperations -from .operations import TopicsOperations -from .operations import DisasterRecoveryConfigsOperations -from .operations import EventHubsOperations -from .operations import MigrationConfigsOperations -from .operations import Operations -from .operations import PremiumMessagingRegionsOperations -from .operations import RulesOperations -from .operations import RegionsOperations -from .operations import SubscriptionsOperations from .. import models +from ._configuration import ServiceBusManagementClientConfiguration +from .operations import DisasterRecoveryConfigsOperations, EventHubsOperations, MigrationConfigsOperations, NamespacesOperations, Operations, PremiumMessagingRegionsOperations, QueuesOperations, RegionsOperations, RulesOperations, SubscriptionsOperations, TopicsOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class ServiceBusManagementClient(object): +class ServiceBusManagementClient: # pylint: disable=too-many-instance-attributes """Azure Service Bus client. :ivar namespaces: NamespacesOperations operations @@ -41,85 +32,91 @@ class ServiceBusManagementClient(object): :ivar topics: TopicsOperations operations :vartype topics: azure.mgmt.servicebus.v2017_04_01.aio.operations.TopicsOperations :ivar disaster_recovery_configs: DisasterRecoveryConfigsOperations operations - :vartype disaster_recovery_configs: azure.mgmt.servicebus.v2017_04_01.aio.operations.DisasterRecoveryConfigsOperations + :vartype disaster_recovery_configs: + azure.mgmt.servicebus.v2017_04_01.aio.operations.DisasterRecoveryConfigsOperations :ivar event_hubs: EventHubsOperations operations :vartype event_hubs: azure.mgmt.servicebus.v2017_04_01.aio.operations.EventHubsOperations :ivar migration_configs: MigrationConfigsOperations operations - :vartype migration_configs: azure.mgmt.servicebus.v2017_04_01.aio.operations.MigrationConfigsOperations + :vartype migration_configs: + azure.mgmt.servicebus.v2017_04_01.aio.operations.MigrationConfigsOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.servicebus.v2017_04_01.aio.operations.Operations :ivar premium_messaging_regions: PremiumMessagingRegionsOperations operations - :vartype premium_messaging_regions: azure.mgmt.servicebus.v2017_04_01.aio.operations.PremiumMessagingRegionsOperations + :vartype premium_messaging_regions: + azure.mgmt.servicebus.v2017_04_01.aio.operations.PremiumMessagingRegionsOperations :ivar rules: RulesOperations operations :vartype rules: azure.mgmt.servicebus.v2017_04_01.aio.operations.RulesOperations :ivar regions: RegionsOperations operations :vartype regions: azure.mgmt.servicebus.v2017_04_01.aio.operations.RegionsOperations :ivar subscriptions: SubscriptionsOperations operations - :vartype subscriptions: azure.mgmt.servicebus.v2017_04_01.aio.operations.SubscriptionsOperations + :vartype subscriptions: + azure.mgmt.servicebus.v2017_04_01.aio.operations.SubscriptionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2017-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = ServiceBusManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ServiceBusManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.namespaces = NamespacesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queues = QueuesOperations(self._client, self._config, self._serialize, self._deserialize) + self.topics = TopicsOperations(self._client, self._config, self._serialize, self._deserialize) + self.disaster_recovery_configs = DisasterRecoveryConfigsOperations(self._client, self._config, self._serialize, self._deserialize) + self.event_hubs = EventHubsOperations(self._client, self._config, self._serialize, self._deserialize) + self.migration_configs = MigrationConfigsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.premium_messaging_regions = PremiumMessagingRegionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.rules = RulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.regions = RegionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.namespaces = NamespacesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.queues = QueuesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.topics = TopicsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.disaster_recovery_configs = DisasterRecoveryConfigsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.event_hubs = EventHubsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.migration_configs = MigrationConfigsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.premium_messaging_regions = PremiumMessagingRegionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.rules = RulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.regions = RegionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_disaster_recovery_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_disaster_recovery_configs_operations.py index b4b2633565f9..212eb81ec640 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_disaster_recovery_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_disaster_recovery_configs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._disaster_recovery_configs_operations import build_break_pairing_request, build_check_name_availability_request, build_create_or_update_request, build_delete_request, build_fail_over_request, build_get_authorization_rule_request, build_get_request, build_list_authorization_rules_request, build_list_keys_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def check_name_availability( self, resource_group_name: str, @@ -66,38 +71,34 @@ async def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CheckNameAvailability') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'CheckNameAvailability') + + request = build_check_name_availability_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) @@ -106,8 +107,11 @@ async def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability"} # type: ignore + + + @distributed_trace def list( self, resource_group_name: str, @@ -121,45 +125,48 @@ def list( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ArmDisasterRecoveryListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.ArmDisasterRecoveryListResult] + :return: An iterator like instance of either ArmDisasterRecoveryListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.ArmDisasterRecoveryListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ArmDisasterRecoveryListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ArmDisasterRecoveryListResult', pipeline_response) + deserialized = self._deserialize("ArmDisasterRecoveryListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -168,21 +175,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs"} # type: ignore + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -211,39 +224,35 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ArmDisasterRecovery') - 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) + + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ArmDisasterRecovery') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -254,9 +263,12 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}'} # type: ignore - async def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -281,41 +293,40 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -341,34 +352,31 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) @@ -377,9 +385,12 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}'} # type: ignore - async def break_pairing( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore + + + @distributed_trace_async + async def break_pairing( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -405,42 +416,41 @@ async def break_pairing( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.break_pairing.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_break_pairing_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.break_pairing.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - break_pairing.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing'} # type: ignore + break_pairing.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing"} # type: ignore + - async def fail_over( + @distributed_trace_async + async def fail_over( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -465,41 +475,40 @@ async def fail_over( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.fail_over.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_fail_over_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.fail_over.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - fail_over.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover'} # type: ignore + fail_over.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover"} # type: ignore + + @distributed_trace def list_authorization_rules( self, resource_group_name: str, @@ -516,46 +525,50 @@ def list_authorization_rules( :param alias: The Disaster Recovery configuration name. :type alias: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRuleListResult] + :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SBAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -564,21 +577,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/AuthorizationRules'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/AuthorizationRules"} # type: ignore + @distributed_trace_async async def get_authorization_rule( self, resource_group_name: str, @@ -607,35 +626,32 @@ async def get_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -644,8 +660,11 @@ async def get_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/AuthorizationRules/{authorizationRuleName}'} # type: ignore + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/AuthorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace_async async def list_keys( self, resource_group_name: str, @@ -674,35 +693,32 @@ async def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -711,4 +727,6 @@ async def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/AuthorizationRules/{authorizationRuleName}/listKeys'} # type: ignore + + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_event_hubs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_event_hubs_operations.py index a1e0e4fd626d..f107c3ac6d14 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_event_hubs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_event_hubs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,19 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._event_hubs_operations import build_list_by_namespace_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_namespace( self, resource_group_name: str, @@ -55,44 +59,46 @@ def list_by_namespace( :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EventHubListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.EventHubListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.EventHubListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_namespace.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_namespace.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('EventHubListResult', pipeline_response) + deserialized = self._deserialize("EventHubListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -101,17 +107,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_namespace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/eventhubs'} # type: ignore + list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/eventhubs"} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_migration_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_migration_configs_operations.py index 7d56babaabd9..a106c9cb24b1 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_migration_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_migration_configs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,19 +6,22 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._migration_configs_operations import build_complete_migration_request, build_create_and_start_migration_request_initial, build_delete_request, build_get_request, build_list_request, build_revert_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +47,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name: str, @@ -56,45 +61,48 @@ def list( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MigrationConfigListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigListResult] + :return: An iterator like instance of either MigrationConfigListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.MigrationConfigListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('MigrationConfigListResult', pipeline_response) + deserialized = self._deserialize("MigrationConfigListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,20 +111,25 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations"} # type: ignore async def _create_and_start_migration_initial( self, @@ -131,40 +144,35 @@ async def _create_and_start_migration_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_and_start_migration_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'MigrationConfigProperties') - 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) + + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'MigrationConfigProperties') + + request = build_create_and_start_migration_request_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_and_start_migration_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -174,8 +182,11 @@ async def _create_and_start_migration_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_and_start_migration_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}'} # type: ignore + _create_and_start_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + + + @distributed_trace_async async def begin_create_and_start_migration( self, resource_group_name: str, @@ -197,14 +208,20 @@ async def begin_create_and_start_migration( :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigProperties :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either MigrationConfigProperties or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigProperties] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MigrationConfigProperties or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigProperties] + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.MigrationConfigProperties"] lro_delay = kwargs.pop( @@ -218,28 +235,22 @@ async def begin_create_and_start_migration( namespace_name=namespace_name, config_name=config_name, parameters=parameters, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -249,11 +260,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_and_start_migration.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_and_start_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore - async def delete( + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -278,41 +290,40 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -338,34 +349,31 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) @@ -374,9 +382,12 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}'} # type: ignore - async def complete_migration( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + + + @distributed_trace_async + async def complete_migration( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -403,42 +414,41 @@ async def complete_migration( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.complete_migration.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_complete_migration_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.complete_migration.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - complete_migration.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade'} # type: ignore + complete_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade"} # type: ignore - async def revert( + + @distributed_trace_async + async def revert( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -463,37 +473,35 @@ async def revert( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.revert.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_revert_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.revert.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - revert.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert'} # type: ignore + revert.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_namespaces_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_namespaces_operations.py index d5f3fa0e9e1d..ba64c82ae3f2 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_namespaces_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_namespaces_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,19 +6,22 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._namespaces_operations import build_check_name_availability_request, build_create_or_update_authorization_rule_request, build_create_or_update_network_rule_set_request, build_create_or_update_request_initial, build_delete_authorization_rule_request, build_delete_request_initial, build_get_authorization_rule_request, build_get_network_rule_set_request, build_get_request, build_list_authorization_rules_request, build_list_by_resource_group_request, build_list_keys_request, build_list_network_rule_sets_request, build_list_request, build_migrate_request, build_regenerate_keys_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +47,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_authorization_rules( self, resource_group_name: str, @@ -56,45 +61,48 @@ def list_authorization_rules( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRuleListResult] + :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SBAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,21 +111,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules"} # type: ignore + @distributed_trace_async async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -146,39 +160,35 @@ async def create_or_update_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBAuthorizationRule') - 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) + + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBAuthorizationRule') + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -187,9 +197,12 @@ async def create_or_update_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}'} # type: ignore - async def delete_authorization_rule( + create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace_async + async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -214,41 +227,40 @@ async def delete_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.delete_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}'} # type: ignore + delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore + + @distributed_trace_async async def get_authorization_rule( self, resource_group_name: str, @@ -274,34 +286,31 @@ async def get_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -310,8 +319,11 @@ async def get_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}'} # type: ignore + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace_async async def list_keys( self, resource_group_name: str, @@ -337,34 +349,31 @@ async def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -373,8 +382,11 @@ async def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore + + + @distributed_trace_async async def regenerate_keys( self, resource_group_name: str, @@ -403,39 +415,35 @@ async def regenerate_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -444,8 +452,11 @@ async def regenerate_keys( return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys'} # type: ignore + regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + + + @distributed_trace_async async def check_name_availability( self, parameters: "_models.CheckNameAvailability", @@ -465,36 +476,32 @@ async def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CheckNameAvailability') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'CheckNameAvailability') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) @@ -503,9 +510,12 @@ async def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability'} # type: ignore - async def migrate( + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability"} # type: ignore + + + @distributed_trace_async + async def migrate( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -530,45 +540,43 @@ async def migrate( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.migrate.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBNamespaceMigrate') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBNamespaceMigrate') + + request = build_migrate_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.migrate.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - migrate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrate'} # type: ignore + migrate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrate"} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -576,43 +584,44 @@ def list( """Gets all the available namespaces within the subscription, irrespective of the resource groups. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBNamespaceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBNamespaceListResult] + :return: An iterator like instance of either SBNamespaceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBNamespaceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBNamespaceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SBNamespaceListResult', pipeline_response) + deserialized = self._deserialize("SBNamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -621,21 +630,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces"} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -646,44 +661,46 @@ def list_by_resource_group( :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBNamespaceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBNamespaceListResult] + :return: An iterator like instance of either SBNamespaceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBNamespaceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBNamespaceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SBNamespaceListResult', pipeline_response) + deserialized = self._deserialize("SBNamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -692,20 +709,25 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces"} # type: ignore async def _create_or_update_initial( self, @@ -719,39 +741,34 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBNamespace') - 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) + + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBNamespace') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -764,8 +781,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -784,14 +804,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either SBNamespace or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either SBNamespace or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace] + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.SBNamespace"] lro_delay = kwargs.pop( @@ -804,27 +830,22 @@ async def begin_create_or_update( resource_group_name=resource_group_name, namespace_name=namespace_name, parameters=parameters, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('SBNamespace', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -834,11 +855,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - async def _delete_initial( + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -849,41 +870,39 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - async def begin_delete( + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -898,14 +917,17 @@ async def begin_delete( :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2017-04-01") # type: str polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( @@ -917,24 +939,18 @@ async def begin_delete( raw_result = await self._delete_initial( resource_group_name=resource_group_name, namespace_name=namespace_name, + api_version=api_version, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -944,10 +960,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -970,33 +987,30 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBNamespace', pipeline_response) @@ -1005,8 +1019,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -1033,38 +1050,34 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -1078,8 +1091,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + + @distributed_trace_async async def create_or_update_network_rule_set( self, resource_group_name: str, @@ -1105,38 +1121,34 @@ async def create_or_update_network_rule_set( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_network_rule_set.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'NetworkRuleSet') - 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) + + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'NetworkRuleSet') + + request = build_create_or_update_network_rule_set_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_network_rule_set.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('NetworkRuleSet', pipeline_response) @@ -1145,8 +1157,11 @@ async def create_or_update_network_rule_set( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_network_rule_set.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default'} # type: ignore + create_or_update_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore + + + @distributed_trace_async async def get_network_rule_set( self, resource_group_name: str, @@ -1169,33 +1184,30 @@ async def get_network_rule_set( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get_network_rule_set.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_network_rule_set_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_network_rule_set.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('NetworkRuleSet', pipeline_response) @@ -1204,8 +1216,11 @@ async def get_network_rule_set( return cls(pipeline_response, deserialized, {}) return deserialized - get_network_rule_set.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default'} # type: ignore + get_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore + + + @distributed_trace def list_network_rule_sets( self, resource_group_name: str, @@ -1219,45 +1234,48 @@ def list_network_rule_sets( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NetworkRuleSetListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleSetListResult] + :return: An iterator like instance of either NetworkRuleSetListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkRuleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_network_rule_sets.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_network_rule_sets_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_network_rule_sets.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_network_rule_sets_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('NetworkRuleSetListResult', pipeline_response) + deserialized = self._deserialize("NetworkRuleSetListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1266,17 +1284,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_network_rule_sets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets'} # type: ignore + list_network_rule_sets.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets"} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_operations.py index 169c562ac22c..f762bbac07e7 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,19 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,38 +53,40 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -89,17 +95,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.ServiceBus/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.ServiceBus/operations"} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_premium_messaging_regions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_premium_messaging_regions_operations.py index dbb42428bfbc..aeccb9381489 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_premium_messaging_regions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_premium_messaging_regions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,19 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._premium_messaging_regions_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -48,43 +52,44 @@ def list( """Gets the available premium messaging regions for servicebus. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PremiumMessagingRegionsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.PremiumMessagingRegionsListResult] + :return: An iterator like instance of either PremiumMessagingRegionsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.PremiumMessagingRegionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.PremiumMessagingRegionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PremiumMessagingRegionsListResult', pipeline_response) + deserialized = self._deserialize("PremiumMessagingRegionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,17 +98,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/premiumMessagingRegions'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/premiumMessagingRegions"} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_queues_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_queues_operations.py index b832d1386831..63beed7e8ca1 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_queues_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_queues_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._queues_operations import build_create_or_update_authorization_rule_request, build_create_or_update_request, build_delete_authorization_rule_request, build_delete_request, build_get_authorization_rule_request, build_get_request, build_list_authorization_rules_request, build_list_by_namespace_request, build_list_keys_request, build_regenerate_keys_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_authorization_rules( self, resource_group_name: str, @@ -57,46 +62,50 @@ def list_authorization_rules( :param queue_name: The queue name. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRuleListResult] + :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SBAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,21 +114,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules"} # type: ignore + @distributed_trace_async async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -151,40 +166,36 @@ async def create_or_update_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBAuthorizationRule') - 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) + + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBAuthorizationRule') + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -193,9 +204,12 @@ async def create_or_update_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}'} # type: ignore - async def delete_authorization_rule( + create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace_async + async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -223,42 +237,41 @@ async def delete_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.delete_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}'} # type: ignore + delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + @distributed_trace_async async def get_authorization_rule( self, resource_group_name: str, @@ -287,35 +300,32 @@ async def get_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -324,8 +334,11 @@ async def get_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}'} # type: ignore + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace_async async def list_keys( self, resource_group_name: str, @@ -354,35 +367,32 @@ async def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -391,8 +401,11 @@ async def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore + + + @distributed_trace_async async def regenerate_keys( self, resource_group_name: str, @@ -424,40 +437,36 @@ async def regenerate_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -466,8 +475,11 @@ async def regenerate_keys( return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys'} # type: ignore + regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + + + @distributed_trace def list_by_namespace( self, resource_group_name: str, @@ -484,54 +496,57 @@ def list_by_namespace( :type namespace_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. + parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip: int :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SBQueueListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBQueueListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBQueueListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBQueueListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_namespace.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', maximum=1000, minimum=0) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=self.list_by_namespace.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SBQueueListResult', pipeline_response) + deserialized = self._deserialize("SBQueueListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -540,21 +555,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_namespace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues'} # type: ignore + list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues"} # type: ignore + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -583,39 +604,35 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBQueue') - 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) + + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBQueue') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBQueue', pipeline_response) @@ -624,9 +641,12 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}'} # type: ignore - async def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -651,41 +671,40 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -711,34 +730,31 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBQueue', pipeline_response) @@ -747,4 +763,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_regions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_regions_operations.py index a58e648745fd..27356747c567 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_regions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_regions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,19 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._regions_operations import build_list_by_sku_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_sku( self, sku: str, @@ -51,44 +55,46 @@ def list_by_sku( :param sku: The sku type. :type sku: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PremiumMessagingRegionsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.PremiumMessagingRegionsListResult] + :return: An iterator like instance of either PremiumMessagingRegionsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.PremiumMessagingRegionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.PremiumMessagingRegionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_sku.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'sku': self._serialize.url("sku", sku, 'str', max_length=50, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_sku_request( + subscription_id=self._config.subscription_id, + sku=sku, + api_version=api_version, + template_url=self.list_by_sku.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_sku_request( + subscription_id=self._config.subscription_id, + sku=sku, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PremiumMessagingRegionsListResult', pipeline_response) + deserialized = self._deserialize("PremiumMessagingRegionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -97,17 +103,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_sku.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/sku/{sku}/regions'} # type: ignore + list_by_sku.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/sku/{sku}/regions"} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_rules_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_rules_operations.py index 7e3556bb8350..848c4b8fade1 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_rules_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_rules_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._rules_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_subscriptions_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_subscriptions( self, resource_group_name: str, @@ -63,56 +68,61 @@ def list_by_subscriptions( :type subscription_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. + parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip: int :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.RuleListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.RuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscriptions.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', maximum=1000, minimum=0) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscriptions_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=self.list_by_subscriptions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscriptions_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RuleListResult', pipeline_response) + deserialized = self._deserialize("RuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -121,21 +131,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_subscriptions.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules'} # type: ignore + list_by_subscriptions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules"} # type: ignore + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -170,41 +186,37 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Rule') - 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) + + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Rule') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Rule', pipeline_response) @@ -213,9 +225,12 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}'} # type: ignore - async def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -246,43 +261,42 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -314,36 +328,33 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Rule', pipeline_response) @@ -352,4 +363,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_subscriptions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_subscriptions_operations.py index 57683192fad1..40891e4b8e18 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_subscriptions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_subscriptions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._subscriptions_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_topic_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_topic( self, resource_group_name: str, @@ -60,55 +65,60 @@ def list_by_topic( :type topic_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. + parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip: int :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBSubscriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBSubscriptionListResult] + :return: An iterator like instance of either SBSubscriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBSubscriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBSubscriptionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_topic.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', maximum=1000, minimum=0) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_topic_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=self.list_by_topic.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_topic_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SBSubscriptionListResult', pipeline_response) + deserialized = self._deserialize("SBSubscriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -117,21 +127,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_topic.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions'} # type: ignore + list_by_topic.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions"} # type: ignore + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -163,40 +179,36 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBSubscription') - 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) + + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBSubscription') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBSubscription', pipeline_response) @@ -205,9 +217,12 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}'} # type: ignore - async def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -235,42 +250,41 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -299,35 +313,32 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBSubscription', pipeline_response) @@ -336,4 +347,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_topics_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_topics_operations.py index 6bed7e1e9734..0735f39feea3 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_topics_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_topics_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._topics_operations import build_create_or_update_authorization_rule_request, build_create_or_update_request, build_delete_authorization_rule_request, build_delete_request, build_get_authorization_rule_request, build_get_request, build_list_authorization_rules_request, build_list_by_namespace_request, build_list_keys_request, build_regenerate_keys_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_authorization_rules( self, resource_group_name: str, @@ -57,46 +62,50 @@ def list_authorization_rules( :param topic_name: The topic name. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRuleListResult] + :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SBAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,21 +114,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules"} # type: ignore + @distributed_trace_async async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -151,40 +166,36 @@ async def create_or_update_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBAuthorizationRule') - 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) + + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBAuthorizationRule') + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -193,8 +204,11 @@ async def create_or_update_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}'} # type: ignore + create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace_async async def get_authorization_rule( self, resource_group_name: str, @@ -223,35 +237,32 @@ async def get_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -260,9 +271,12 @@ async def get_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}'} # type: ignore - async def delete_authorization_rule( + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace_async + async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -290,42 +304,41 @@ async def delete_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.delete_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}'} # type: ignore + delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + @distributed_trace_async async def list_keys( self, resource_group_name: str, @@ -354,35 +367,32 @@ async def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -391,8 +401,11 @@ async def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore + + + @distributed_trace_async async def regenerate_keys( self, resource_group_name: str, @@ -424,40 +437,36 @@ async def regenerate_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -466,8 +475,11 @@ async def regenerate_keys( return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys'} # type: ignore + regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + + + @distributed_trace def list_by_namespace( self, resource_group_name: str, @@ -484,54 +496,57 @@ def list_by_namespace( :type namespace_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. + parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip: int :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SBTopicListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBTopicListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBTopicListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBTopicListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_namespace.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', maximum=1000, minimum=0) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=self.list_by_namespace.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SBTopicListResult', pipeline_response) + deserialized = self._deserialize("SBTopicListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -540,21 +555,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_namespace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics'} # type: ignore + list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics"} # type: ignore + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -583,39 +604,35 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBTopic') - 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) + + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBTopic') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBTopic', pipeline_response) @@ -624,9 +641,12 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}'} # type: ignore - async def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -651,41 +671,40 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -711,34 +730,31 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBTopic', pipeline_response) @@ -747,4 +763,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/models/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/models/__init__.py index 80f9a1628e4d..ff6852ee7e97 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/models/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/models/__init__.py @@ -6,106 +6,56 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import AccessKeys - from ._models_py3 import Action - from ._models_py3 import ArmDisasterRecovery - from ._models_py3 import ArmDisasterRecoveryListResult - from ._models_py3 import CaptureDescription - from ._models_py3 import CheckNameAvailability - from ._models_py3 import CheckNameAvailabilityResult - from ._models_py3 import CorrelationFilter - from ._models_py3 import Destination - from ._models_py3 import ErrorAdditionalInfo - from ._models_py3 import ErrorResponse - from ._models_py3 import ErrorResponseError - from ._models_py3 import EventHubListResult - from ._models_py3 import Eventhub - from ._models_py3 import MessageCountDetails - from ._models_py3 import MigrationConfigListResult - from ._models_py3 import MigrationConfigProperties - from ._models_py3 import NWRuleSetIpRules - from ._models_py3 import NWRuleSetVirtualNetworkRules - from ._models_py3 import NetworkRuleSet - from ._models_py3 import NetworkRuleSetListResult - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationListResult - from ._models_py3 import PremiumMessagingRegions - from ._models_py3 import PremiumMessagingRegionsListResult - from ._models_py3 import PremiumMessagingRegionsProperties - from ._models_py3 import RegenerateAccessKeyParameters - from ._models_py3 import Resource - from ._models_py3 import ResourceNamespacePatch - from ._models_py3 import Rule - from ._models_py3 import RuleListResult - from ._models_py3 import SBAuthorizationRule - from ._models_py3 import SBAuthorizationRuleListResult - from ._models_py3 import SBNamespace - from ._models_py3 import SBNamespaceListResult - from ._models_py3 import SBNamespaceMigrate - from ._models_py3 import SBNamespaceUpdateParameters - from ._models_py3 import SBQueue - from ._models_py3 import SBQueueListResult - from ._models_py3 import SBSku - from ._models_py3 import SBSubscription - from ._models_py3 import SBSubscriptionListResult - from ._models_py3 import SBTopic - from ._models_py3 import SBTopicListResult - from ._models_py3 import SqlFilter - from ._models_py3 import SqlRuleAction - from ._models_py3 import Subnet - from ._models_py3 import TrackedResource -except (SyntaxError, ImportError): - from ._models import AccessKeys # type: ignore - from ._models import Action # type: ignore - from ._models import ArmDisasterRecovery # type: ignore - from ._models import ArmDisasterRecoveryListResult # type: ignore - from ._models import CaptureDescription # type: ignore - from ._models import CheckNameAvailability # type: ignore - from ._models import CheckNameAvailabilityResult # type: ignore - from ._models import CorrelationFilter # type: ignore - from ._models import Destination # type: ignore - from ._models import ErrorAdditionalInfo # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import ErrorResponseError # type: ignore - from ._models import EventHubListResult # type: ignore - from ._models import Eventhub # type: ignore - from ._models import MessageCountDetails # type: ignore - from ._models import MigrationConfigListResult # type: ignore - from ._models import MigrationConfigProperties # type: ignore - from ._models import NWRuleSetIpRules # type: ignore - from ._models import NWRuleSetVirtualNetworkRules # type: ignore - from ._models import NetworkRuleSet # type: ignore - from ._models import NetworkRuleSetListResult # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import PremiumMessagingRegions # type: ignore - from ._models import PremiumMessagingRegionsListResult # type: ignore - from ._models import PremiumMessagingRegionsProperties # type: ignore - from ._models import RegenerateAccessKeyParameters # type: ignore - from ._models import Resource # type: ignore - from ._models import ResourceNamespacePatch # type: ignore - from ._models import Rule # type: ignore - from ._models import RuleListResult # type: ignore - from ._models import SBAuthorizationRule # type: ignore - from ._models import SBAuthorizationRuleListResult # type: ignore - from ._models import SBNamespace # type: ignore - from ._models import SBNamespaceListResult # type: ignore - from ._models import SBNamespaceMigrate # type: ignore - from ._models import SBNamespaceUpdateParameters # type: ignore - from ._models import SBQueue # type: ignore - from ._models import SBQueueListResult # type: ignore - from ._models import SBSku # type: ignore - from ._models import SBSubscription # type: ignore - from ._models import SBSubscriptionListResult # type: ignore - from ._models import SBTopic # type: ignore - from ._models import SBTopicListResult # type: ignore - from ._models import SqlFilter # type: ignore - from ._models import SqlRuleAction # type: ignore - from ._models import Subnet # type: ignore - from ._models import TrackedResource # type: ignore +from ._models_py3 import AccessKeys +from ._models_py3 import Action +from ._models_py3 import ArmDisasterRecovery +from ._models_py3 import ArmDisasterRecoveryListResult +from ._models_py3 import CaptureDescription +from ._models_py3 import CheckNameAvailability +from ._models_py3 import CheckNameAvailabilityResult +from ._models_py3 import CorrelationFilter +from ._models_py3 import Destination +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorResponse +from ._models_py3 import ErrorResponseError +from ._models_py3 import EventHubListResult +from ._models_py3 import Eventhub +from ._models_py3 import MessageCountDetails +from ._models_py3 import MigrationConfigListResult +from ._models_py3 import MigrationConfigProperties +from ._models_py3 import NWRuleSetIpRules +from ._models_py3 import NWRuleSetVirtualNetworkRules +from ._models_py3 import NetworkRuleSet +from ._models_py3 import NetworkRuleSetListResult +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import PremiumMessagingRegions +from ._models_py3 import PremiumMessagingRegionsListResult +from ._models_py3 import PremiumMessagingRegionsProperties +from ._models_py3 import RegenerateAccessKeyParameters +from ._models_py3 import Resource +from ._models_py3 import ResourceNamespacePatch +from ._models_py3 import Rule +from ._models_py3 import RuleListResult +from ._models_py3 import SBAuthorizationRule +from ._models_py3 import SBAuthorizationRuleListResult +from ._models_py3 import SBNamespace +from ._models_py3 import SBNamespaceListResult +from ._models_py3 import SBNamespaceMigrate +from ._models_py3 import SBNamespaceUpdateParameters +from ._models_py3 import SBQueue +from ._models_py3 import SBQueueListResult +from ._models_py3 import SBSku +from ._models_py3 import SBSubscription +from ._models_py3 import SBSubscriptionListResult +from ._models_py3 import SBTopic +from ._models_py3 import SBTopicListResult +from ._models_py3 import SqlFilter +from ._models_py3 import SqlRuleAction +from ._models_py3 import Subnet +from ._models_py3 import TrackedResource + from ._service_bus_management_client_enums import ( AccessRights, diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/models/_models.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/models/_models.py deleted file mode 100644 index 9d8d819f83a4..000000000000 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/models/_models.py +++ /dev/null @@ -1,2057 +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 azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class AccessKeys(msrest.serialization.Model): - """Namespace/ServiceBus Connection String. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar primary_connection_string: Primary connection string of the created namespace - authorization rule. - :vartype primary_connection_string: str - :ivar secondary_connection_string: Secondary connection string of the created namespace - authorization rule. - :vartype secondary_connection_string: str - :ivar alias_primary_connection_string: Primary connection string of the alias if GEO DR is - enabled. - :vartype alias_primary_connection_string: str - :ivar alias_secondary_connection_string: Secondary connection string of the alias if GEO DR is - enabled. - :vartype alias_secondary_connection_string: str - :ivar primary_key: A base64-encoded 256-bit primary key for signing and validating the SAS - token. - :vartype primary_key: str - :ivar secondary_key: A base64-encoded 256-bit primary key for signing and validating the SAS - token. - :vartype secondary_key: str - :ivar key_name: A string that describes the authorization rule. - :vartype key_name: str - """ - - _validation = { - 'primary_connection_string': {'readonly': True}, - 'secondary_connection_string': {'readonly': True}, - 'alias_primary_connection_string': {'readonly': True}, - 'alias_secondary_connection_string': {'readonly': True}, - 'primary_key': {'readonly': True}, - 'secondary_key': {'readonly': True}, - 'key_name': {'readonly': True}, - } - - _attribute_map = { - 'primary_connection_string': {'key': 'primaryConnectionString', 'type': 'str'}, - 'secondary_connection_string': {'key': 'secondaryConnectionString', 'type': 'str'}, - 'alias_primary_connection_string': {'key': 'aliasPrimaryConnectionString', 'type': 'str'}, - 'alias_secondary_connection_string': {'key': 'aliasSecondaryConnectionString', 'type': 'str'}, - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, - 'key_name': {'key': 'keyName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AccessKeys, self).__init__(**kwargs) - self.primary_connection_string = None - self.secondary_connection_string = None - self.alias_primary_connection_string = None - self.alias_secondary_connection_string = None - self.primary_key = None - self.secondary_key = None - self.key_name = None - - -class Action(msrest.serialization.Model): - """Represents the filter actions which are allowed for the transformation of a message that have been matched by a filter expression. - - :param sql_expression: SQL expression. e.g. MyProperty='ABC'. - :type sql_expression: str - :param compatibility_level: This property is reserved for future use. An integer value showing - the compatibility level, currently hard-coded to 20. - :type compatibility_level: int - :param requires_preprocessing: Value that indicates whether the rule action requires - preprocessing. - :type requires_preprocessing: bool - """ - - _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(Action, self).__init__(**kwargs) - self.sql_expression = kwargs.get('sql_expression', None) - self.compatibility_level = kwargs.get('compatibility_level', None) - self.requires_preprocessing = kwargs.get('requires_preprocessing', True) - - -class Resource(msrest.serialization.Model): - """The Resource definition for other than namespace. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class ArmDisasterRecovery(Resource): - """Single item in List or Get Alias(Disaster Recovery configuration) operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar provisioning_state: Provisioning state of the Alias(Disaster Recovery configuration) - - possible values 'Accepted' or 'Succeeded' or 'Failed'. Possible values include: "Accepted", - "Succeeded", "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.servicebus.v2017_04_01.models.ProvisioningStateDR - :ivar pending_replication_operations_count: Number of entities pending to be replicated. - :vartype pending_replication_operations_count: long - :param partner_namespace: ARM Id of the Primary/Secondary eventhub namespace name, which is - part of GEO DR pairing. - :type partner_namespace: str - :param alternate_name: Primary/Secondary eventhub namespace name, which is part of GEO DR - pairing. - :type alternate_name: str - :ivar role: role of namespace in GEO DR - possible values 'Primary' or 'PrimaryNotReplicating' - or 'Secondary'. Possible values include: "Primary", "PrimaryNotReplicating", "Secondary". - :vartype role: str or ~azure.mgmt.servicebus.v2017_04_01.models.RoleDisasterRecovery - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'pending_replication_operations_count': {'readonly': True}, - 'role': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'pending_replication_operations_count': {'key': 'properties.pendingReplicationOperationsCount', 'type': 'long'}, - 'partner_namespace': {'key': 'properties.partnerNamespace', 'type': 'str'}, - 'alternate_name': {'key': 'properties.alternateName', 'type': 'str'}, - 'role': {'key': 'properties.role', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ArmDisasterRecovery, self).__init__(**kwargs) - self.provisioning_state = None - self.pending_replication_operations_count = None - self.partner_namespace = kwargs.get('partner_namespace', None) - self.alternate_name = kwargs.get('alternate_name', None) - self.role = None - - -class ArmDisasterRecoveryListResult(msrest.serialization.Model): - """The result of the List Alias(Disaster Recovery configuration) operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: List of Alias(Disaster Recovery configurations). - :type value: list[~azure.mgmt.servicebus.v2017_04_01.models.ArmDisasterRecovery] - :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list - of Alias(Disaster Recovery configuration). - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ArmDisasterRecovery]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ArmDisasterRecoveryListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class CaptureDescription(msrest.serialization.Model): - """Properties to configure capture description for eventhub. - - :param enabled: A value that indicates whether capture description is enabled. - :type enabled: bool - :param encoding: Enumerates the possible values for the encoding format of capture description. - Possible values include: "Avro", "AvroDeflate". - :type encoding: str or ~azure.mgmt.servicebus.v2017_04_01.models.EncodingCaptureDescription - :param interval_in_seconds: The time window allows you to set the frequency with which the - capture to Azure Blobs will happen, value should between 60 to 900 seconds. - :type interval_in_seconds: int - :param size_limit_in_bytes: The size window defines the amount of data built up in your Event - Hub before an capture operation, value should be between 10485760 and 524288000 bytes. - :type size_limit_in_bytes: int - :param destination: Properties of Destination where capture will be stored. (Storage Account, - Blob Names). - :type destination: ~azure.mgmt.servicebus.v2017_04_01.models.Destination - """ - - _validation = { - 'interval_in_seconds': {'maximum': 900, 'minimum': 60}, - 'size_limit_in_bytes': {'maximum': 524288000, 'minimum': 10485760}, - } - - _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'encoding': {'key': 'encoding', 'type': 'str'}, - 'interval_in_seconds': {'key': 'intervalInSeconds', 'type': 'int'}, - 'size_limit_in_bytes': {'key': 'sizeLimitInBytes', 'type': 'int'}, - 'destination': {'key': 'destination', 'type': 'Destination'}, - } - - def __init__( - self, - **kwargs - ): - super(CaptureDescription, self).__init__(**kwargs) - self.enabled = kwargs.get('enabled', None) - self.encoding = kwargs.get('encoding', None) - self.interval_in_seconds = kwargs.get('interval_in_seconds', None) - self.size_limit_in_bytes = kwargs.get('size_limit_in_bytes', None) - self.destination = kwargs.get('destination', None) - - -class CheckNameAvailability(msrest.serialization.Model): - """Description of a Check Name availability request properties. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The Name to check the namespace name availability and The namespace name - can contain only letters, numbers, and hyphens. The namespace must start with a letter, and it - must end with a letter or number. - :type name: str - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CheckNameAvailability, self).__init__(**kwargs) - self.name = kwargs['name'] - - -class CheckNameAvailabilityResult(msrest.serialization.Model): - """Description of a Check Name availability request properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar message: The detailed info regarding the reason associated with the namespace. - :vartype message: str - :param name_available: Value indicating namespace is availability, true if the namespace is - available; otherwise, false. - :type name_available: bool - :param reason: The reason for unavailability of a namespace. Possible values include: "None", - "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", - "TooManyNamespaceInCurrentSubscription". - :type reason: str or ~azure.mgmt.servicebus.v2017_04_01.models.UnavailableReason - """ - - _validation = { - 'message': {'readonly': True}, - } - - _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CheckNameAvailabilityResult, self).__init__(**kwargs) - self.message = None - self.name_available = kwargs.get('name_available', None) - self.reason = kwargs.get('reason', None) - - -class CorrelationFilter(msrest.serialization.Model): - """Represents the correlation filter expression. - - :param properties: dictionary object for custom filters. - :type properties: dict[str, str] - :param correlation_id: Identifier of the correlation. - :type correlation_id: str - :param message_id: Identifier of the message. - :type message_id: str - :param to: Address to send to. - :type to: str - :param reply_to: Address of the queue to reply to. - :type reply_to: str - :param label: Application specific label. - :type label: str - :param session_id: Session identifier. - :type session_id: str - :param reply_to_session_id: Session identifier to reply to. - :type reply_to_session_id: str - :param content_type: Content type of the message. - :type content_type: str - :param requires_preprocessing: Value that indicates whether the rule action requires - preprocessing. - :type requires_preprocessing: bool - """ - - _attribute_map = { - 'properties': {'key': 'properties', 'type': '{str}'}, - 'correlation_id': {'key': 'correlationId', 'type': 'str'}, - 'message_id': {'key': 'messageId', 'type': 'str'}, - 'to': {'key': 'to', 'type': 'str'}, - 'reply_to': {'key': 'replyTo', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'session_id': {'key': 'sessionId', 'type': 'str'}, - 'reply_to_session_id': {'key': 'replyToSessionId', 'type': 'str'}, - 'content_type': {'key': 'contentType', 'type': 'str'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(CorrelationFilter, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - 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.requires_preprocessing = kwargs.get('requires_preprocessing', True) - - -class Destination(msrest.serialization.Model): - """Capture storage details for capture description. - - :param name: Name for capture destination. - :type name: str - :param storage_account_resource_id: Resource id of the storage account to be used to create the - blobs. - :type storage_account_resource_id: str - :param blob_container: Blob container Name. - :type blob_container: str - :param archive_name_format: Blob naming convention for archive, e.g. - {Namespace}/{EventHub}/{PartitionId}/{Year}/{Month}/{Day}/{Hour}/{Minute}/{Second}. Here all - the parameters (Namespace,EventHub .. etc) are mandatory irrespective of order. - :type archive_name_format: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'storage_account_resource_id': {'key': 'properties.storageAccountResourceId', 'type': 'str'}, - 'blob_container': {'key': 'properties.blobContainer', 'type': 'str'}, - 'archive_name_format': {'key': 'properties.archiveNameFormat', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Destination, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.storage_account_resource_id = kwargs.get('storage_account_resource_id', None) - self.blob_container = kwargs.get('blob_container', None) - self.archive_name_format = kwargs.get('archive_name_format', None) - - -class ErrorAdditionalInfo(msrest.serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: any - """ - - _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorAdditionalInfo, self).__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorResponse(msrest.serialization.Model): - """The resource management error response. - - :param error: The error object. - :type error: ~azure.mgmt.servicebus.v2017_04_01.models.ErrorResponseError - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseError'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class ErrorResponseError(msrest.serialization.Model): - """The error object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.servicebus.v2017_04_01.models.ErrorResponse] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~azure.mgmt.servicebus.v2017_04_01.models.ErrorAdditionalInfo] - """ - - _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponseError, self).__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class Eventhub(Resource): - """Single item in List or Get Event Hub operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar partition_ids: Current number of shards on the Event Hub. - :vartype partition_ids: list[str] - :ivar created_at: Exact time the Event Hub was created. - :vartype created_at: ~datetime.datetime - :ivar updated_at: The exact time the message was updated. - :vartype updated_at: ~datetime.datetime - :param message_retention_in_days: Number of days to retain the events for this Event Hub, value - should be 1 to 7 days. - :type message_retention_in_days: long - :param partition_count: Number of partitions created for the Event Hub, allowed values are from - 1 to 32 partitions. - :type partition_count: long - :param status: Enumerates the possible values for the status of a Event Hub. Possible values - include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". - :type status: str or ~azure.mgmt.servicebus.v2017_04_01.models.EntityStatus - :param capture_description: Properties of capture description. - :type capture_description: ~azure.mgmt.servicebus.v2017_04_01.models.CaptureDescription - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'partition_ids': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'message_retention_in_days': {'maximum': 7, 'minimum': 1}, - 'partition_count': {'maximum': 32, 'minimum': 1}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'partition_ids': {'key': 'properties.partitionIds', 'type': '[str]'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'message_retention_in_days': {'key': 'properties.messageRetentionInDays', 'type': 'long'}, - 'partition_count': {'key': 'properties.partitionCount', 'type': 'long'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'capture_description': {'key': 'properties.captureDescription', 'type': 'CaptureDescription'}, - } - - def __init__( - self, - **kwargs - ): - super(Eventhub, self).__init__(**kwargs) - self.partition_ids = None - self.created_at = None - self.updated_at = None - self.message_retention_in_days = kwargs.get('message_retention_in_days', None) - self.partition_count = kwargs.get('partition_count', None) - self.status = kwargs.get('status', None) - self.capture_description = kwargs.get('capture_description', None) - - -class EventHubListResult(msrest.serialization.Model): - """The result of the List EventHubs operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: Result of the List EventHubs operation. - :type value: list[~azure.mgmt.servicebus.v2017_04_01.models.Eventhub] - :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list - of EventHubs. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Eventhub]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EventHubListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class MessageCountDetails(msrest.serialization.Model): - """Message Count Details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar active_message_count: Number of active messages in the queue, topic, or subscription. - :vartype active_message_count: long - :ivar dead_letter_message_count: Number of messages that are dead lettered. - :vartype dead_letter_message_count: long - :ivar scheduled_message_count: Number of scheduled messages. - :vartype scheduled_message_count: long - :ivar transfer_message_count: Number of messages transferred to another queue, topic, or - subscription. - :vartype transfer_message_count: long - :ivar transfer_dead_letter_message_count: Number of messages transferred into dead letters. - :vartype transfer_dead_letter_message_count: long - """ - - _validation = { - 'active_message_count': {'readonly': True}, - 'dead_letter_message_count': {'readonly': True}, - 'scheduled_message_count': {'readonly': True}, - 'transfer_message_count': {'readonly': True}, - 'transfer_dead_letter_message_count': {'readonly': True}, - } - - _attribute_map = { - 'active_message_count': {'key': 'activeMessageCount', 'type': 'long'}, - 'dead_letter_message_count': {'key': 'deadLetterMessageCount', 'type': 'long'}, - 'scheduled_message_count': {'key': 'scheduledMessageCount', 'type': 'long'}, - 'transfer_message_count': {'key': 'transferMessageCount', 'type': 'long'}, - 'transfer_dead_letter_message_count': {'key': 'transferDeadLetterMessageCount', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(MessageCountDetails, self).__init__(**kwargs) - self.active_message_count = None - self.dead_letter_message_count = None - self.scheduled_message_count = None - self.transfer_message_count = None - self.transfer_dead_letter_message_count = None - - -class MigrationConfigListResult(msrest.serialization.Model): - """The result of the List migrationConfigurations operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: List of Migration Configs. - :type value: list[~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigProperties] - :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list - of migrationConfigurations. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[MigrationConfigProperties]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MigrationConfigListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class MigrationConfigProperties(Resource): - """Single item in List or Get Migration Config operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar provisioning_state: Provisioning state of Migration Configuration. - :vartype provisioning_state: str - :ivar pending_replication_operations_count: Number of entities pending to be replicated. - :vartype pending_replication_operations_count: long - :param target_namespace: Existing premium Namespace ARM Id name which has no entities, will be - used for migration. - :type target_namespace: str - :param post_migration_name: Name to access Standard Namespace after migration. - :type post_migration_name: str - :ivar migration_state: State in which Standard to Premium Migration is, possible values : - Unknown, Reverting, Completing, Initiating, Syncing, Active. - :vartype migration_state: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'pending_replication_operations_count': {'readonly': True}, - 'migration_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'pending_replication_operations_count': {'key': 'properties.pendingReplicationOperationsCount', 'type': 'long'}, - 'target_namespace': {'key': 'properties.targetNamespace', 'type': 'str'}, - 'post_migration_name': {'key': 'properties.postMigrationName', 'type': 'str'}, - 'migration_state': {'key': 'properties.migrationState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MigrationConfigProperties, self).__init__(**kwargs) - self.provisioning_state = None - self.pending_replication_operations_count = None - self.target_namespace = kwargs.get('target_namespace', None) - self.post_migration_name = kwargs.get('post_migration_name', None) - self.migration_state = None - - -class NetworkRuleSet(Resource): - """Description of NetworkRuleSet resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param default_action: Default Action for Network Rule Set. Possible values include: "Allow", - "Deny". - :type default_action: str or ~azure.mgmt.servicebus.v2017_04_01.models.DefaultAction - :param virtual_network_rules: List VirtualNetwork Rules. - :type virtual_network_rules: - list[~azure.mgmt.servicebus.v2017_04_01.models.NWRuleSetVirtualNetworkRules] - :param ip_rules: List of IpRules. - :type ip_rules: list[~azure.mgmt.servicebus.v2017_04_01.models.NWRuleSetIpRules] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'default_action': {'key': 'properties.defaultAction', 'type': 'str'}, - 'virtual_network_rules': {'key': 'properties.virtualNetworkRules', 'type': '[NWRuleSetVirtualNetworkRules]'}, - 'ip_rules': {'key': 'properties.ipRules', 'type': '[NWRuleSetIpRules]'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkRuleSet, self).__init__(**kwargs) - self.default_action = kwargs.get('default_action', None) - self.virtual_network_rules = kwargs.get('virtual_network_rules', None) - self.ip_rules = kwargs.get('ip_rules', None) - - -class NetworkRuleSetListResult(msrest.serialization.Model): - """The response of the List NetworkRuleSet operation. - - :param value: Result of the List NetworkRuleSet operation. - :type value: list[~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleSet] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list - of NetworkRuleSet. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[NetworkRuleSet]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkRuleSetListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class NWRuleSetIpRules(msrest.serialization.Model): - """Description of NetWorkRuleSet - IpRules resource. - - :param ip_mask: IP Mask. - :type ip_mask: str - :param action: The IP Filter Action. Possible values include: "Allow". Default value: "Allow". - :type action: str or ~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleIPAction - """ - - _attribute_map = { - 'ip_mask': {'key': 'ipMask', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NWRuleSetIpRules, self).__init__(**kwargs) - self.ip_mask = kwargs.get('ip_mask', None) - self.action = kwargs.get('action', "Allow") - - -class NWRuleSetVirtualNetworkRules(msrest.serialization.Model): - """Description of VirtualNetworkRules - NetworkRules resource. - - :param subnet: Subnet properties. - :type subnet: ~azure.mgmt.servicebus.v2017_04_01.models.Subnet - :param ignore_missing_vnet_service_endpoint: Value that indicates whether to ignore missing - VNet Service Endpoint. - :type ignore_missing_vnet_service_endpoint: bool - """ - - _attribute_map = { - 'subnet': {'key': 'subnet', 'type': 'Subnet'}, - 'ignore_missing_vnet_service_endpoint': {'key': 'ignoreMissingVnetServiceEndpoint', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(NWRuleSetVirtualNetworkRules, self).__init__(**kwargs) - self.subnet = kwargs.get('subnet', None) - self.ignore_missing_vnet_service_endpoint = kwargs.get('ignore_missing_vnet_service_endpoint', None) - - -class Operation(msrest.serialization.Model): - """A ServiceBus REST API operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Operation name: {provider}/{resource}/{operation}. - :vartype name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.servicebus.v2017_04_01.models.OperationDisplay - """ - - _validation = { - 'name': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = None - self.display = kwargs.get('display', None) - - -class OperationDisplay(msrest.serialization.Model): - """The object that represents the operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provider: Service provider: Microsoft.ServiceBus. - :vartype provider: str - :ivar resource: Resource on which the operation is performed: Invoice, etc. - :vartype resource: str - :ivar operation: Operation type: Read, write, delete, etc. - :vartype operation: str - """ - - _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, - } - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - - -class OperationListResult(msrest.serialization.Model): - """Result of the request to list ServiceBus operations. It contains a list of operations and a URL link to get the next set of results. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of ServiceBus operations supported by the Microsoft.ServiceBus resource - provider. - :vartype value: list[~azure.mgmt.servicebus.v2017_04_01.models.Operation] - :ivar next_link: URL to get the next set of operation list results if there are any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ResourceNamespacePatch(Resource): - """The Resource definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceNamespacePatch, self).__init__(**kwargs) - self.location = kwargs.get('location', None) - self.tags = kwargs.get('tags', None) - - -class PremiumMessagingRegions(ResourceNamespacePatch): - """Premium Messaging Region. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param properties: - :type properties: ~azure.mgmt.servicebus.v2017_04_01.models.PremiumMessagingRegionsProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'properties': {'key': 'properties', 'type': 'PremiumMessagingRegionsProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(PremiumMessagingRegions, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class PremiumMessagingRegionsListResult(msrest.serialization.Model): - """The response of the List PremiumMessagingRegions operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: Result of the List PremiumMessagingRegions type. - :type value: list[~azure.mgmt.servicebus.v2017_04_01.models.PremiumMessagingRegions] - :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list - of PremiumMessagingRegions. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[PremiumMessagingRegions]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PremiumMessagingRegionsListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class PremiumMessagingRegionsProperties(msrest.serialization.Model): - """PremiumMessagingRegionsProperties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: Region code. - :vartype code: str - :ivar full_name: Full name of the region. - :vartype full_name: str - """ - - _validation = { - 'code': {'readonly': True}, - 'full_name': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'full_name': {'key': 'fullName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PremiumMessagingRegionsProperties, self).__init__(**kwargs) - self.code = None - self.full_name = None - - -class RegenerateAccessKeyParameters(msrest.serialization.Model): - """Parameters supplied to the Regenerate Authorization Rule operation, specifies which key needs to be reset. - - All required parameters must be populated in order to send to Azure. - - :param key_type: Required. The access key to regenerate. Possible values include: "PrimaryKey", - "SecondaryKey". - :type key_type: str or ~azure.mgmt.servicebus.v2017_04_01.models.KeyType - :param key: Optional, if the key value provided, is reset for KeyType value or autogenerate Key - value set for keyType. - :type key: str - """ - - _validation = { - 'key_type': {'required': True}, - } - - _attribute_map = { - 'key_type': {'key': 'keyType', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RegenerateAccessKeyParameters, self).__init__(**kwargs) - self.key_type = kwargs['key_type'] - self.key = kwargs.get('key', None) - - -class Rule(Resource): - """Description of Rule Resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param action: Represents the filter actions which are allowed for the transformation of a - message that have been matched by a filter expression. - :type action: ~azure.mgmt.servicebus.v2017_04_01.models.Action - :param filter_type: Filter type that is evaluated against a BrokeredMessage. Possible values - include: "SqlFilter", "CorrelationFilter". - :type filter_type: str or ~azure.mgmt.servicebus.v2017_04_01.models.FilterType - :param sql_filter: Properties of sqlFilter. - :type sql_filter: ~azure.mgmt.servicebus.v2017_04_01.models.SqlFilter - :param correlation_filter: Properties of correlationFilter. - :type correlation_filter: ~azure.mgmt.servicebus.v2017_04_01.models.CorrelationFilter - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'action': {'key': 'properties.action', 'type': 'Action'}, - 'filter_type': {'key': 'properties.filterType', 'type': 'str'}, - 'sql_filter': {'key': 'properties.sqlFilter', 'type': 'SqlFilter'}, - 'correlation_filter': {'key': 'properties.correlationFilter', 'type': 'CorrelationFilter'}, - } - - def __init__( - self, - **kwargs - ): - super(Rule, self).__init__(**kwargs) - self.action = kwargs.get('action', None) - self.filter_type = kwargs.get('filter_type', None) - self.sql_filter = kwargs.get('sql_filter', None) - self.correlation_filter = kwargs.get('correlation_filter', None) - - -class RuleListResult(msrest.serialization.Model): - """The response of the List rule operation. - - :param value: Result of the List Rules operation. - :type value: list[~azure.mgmt.servicebus.v2017_04_01.models.Rule] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list - of rules. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Rule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RuleListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class SBAuthorizationRule(Resource): - """Description of a namespace authorization rule. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param rights: The rights associated with the rule. - :type rights: list[str or ~azure.mgmt.servicebus.v2017_04_01.models.AccessRights] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'rights': {'key': 'properties.rights', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(SBAuthorizationRule, self).__init__(**kwargs) - self.rights = kwargs.get('rights', None) - - -class SBAuthorizationRuleListResult(msrest.serialization.Model): - """The response to the List Namespace operation. - - :param value: Result of the List Authorization Rules operation. - :type value: list[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list - of Authorization Rules. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SBAuthorizationRule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SBAuthorizationRuleListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class TrackedResource(Resource): - """The Resource definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: Required. The Geo-location where the resource lives. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(TrackedResource, self).__init__(**kwargs) - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class SBNamespace(TrackedResource): - """Description of a namespace resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: Required. The Geo-location where the resource lives. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param sku: Properties of Sku. - :type sku: ~azure.mgmt.servicebus.v2017_04_01.models.SBSku - :ivar provisioning_state: Provisioning state of the namespace. - :vartype provisioning_state: str - :ivar created_at: The time the namespace was created. - :vartype created_at: ~datetime.datetime - :ivar updated_at: The time the namespace was updated. - :vartype updated_at: ~datetime.datetime - :ivar service_bus_endpoint: Endpoint you can use to perform Service Bus operations. - :vartype service_bus_endpoint: str - :ivar metric_id: Identifier for Azure Insights metrics. - :vartype metric_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'service_bus_endpoint': {'readonly': True}, - 'metric_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'sku', 'type': 'SBSku'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'service_bus_endpoint': {'key': 'properties.serviceBusEndpoint', 'type': 'str'}, - 'metric_id': {'key': 'properties.metricId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SBNamespace, self).__init__(**kwargs) - self.sku = kwargs.get('sku', None) - self.provisioning_state = None - self.created_at = None - self.updated_at = None - self.service_bus_endpoint = None - self.metric_id = None - - -class SBNamespaceListResult(msrest.serialization.Model): - """The response of the List Namespace operation. - - :param value: Result of the List Namespace operation. - :type value: list[~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list - of Namespaces. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SBNamespace]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SBNamespaceListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class SBNamespaceMigrate(msrest.serialization.Model): - """Namespace Migrate Object. - - All required parameters must be populated in order to send to Azure. - - :param target_namespace_type: Required. Type of namespaces. Possible values include: - "Messaging", "NotificationHub", "Mixed", "EventHub", "Relay". - :type target_namespace_type: str or ~azure.mgmt.servicebus.v2017_04_01.models.NameSpaceType - """ - - _validation = { - 'target_namespace_type': {'required': True}, - } - - _attribute_map = { - 'target_namespace_type': {'key': 'targetNamespaceType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SBNamespaceMigrate, self).__init__(**kwargs) - self.target_namespace_type = kwargs['target_namespace_type'] - - -class SBNamespaceUpdateParameters(ResourceNamespacePatch): - """Description of a namespace resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param sku: Properties of Sku. - :type sku: ~azure.mgmt.servicebus.v2017_04_01.models.SBSku - :ivar provisioning_state: Provisioning state of the namespace. - :vartype provisioning_state: str - :ivar created_at: The time the namespace was created. - :vartype created_at: ~datetime.datetime - :ivar updated_at: The time the namespace was updated. - :vartype updated_at: ~datetime.datetime - :ivar service_bus_endpoint: Endpoint you can use to perform Service Bus operations. - :vartype service_bus_endpoint: str - :ivar metric_id: Identifier for Azure Insights metrics. - :vartype metric_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'service_bus_endpoint': {'readonly': True}, - 'metric_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'sku', 'type': 'SBSku'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'service_bus_endpoint': {'key': 'properties.serviceBusEndpoint', 'type': 'str'}, - 'metric_id': {'key': 'properties.metricId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SBNamespaceUpdateParameters, self).__init__(**kwargs) - self.sku = kwargs.get('sku', None) - self.provisioning_state = None - self.created_at = None - self.updated_at = None - self.service_bus_endpoint = None - self.metric_id = None - - -class SBQueue(Resource): - """Description of queue Resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar count_details: Message Count Details. - :vartype count_details: ~azure.mgmt.servicebus.v2017_04_01.models.MessageCountDetails - :ivar created_at: The exact time the message was created. - :vartype created_at: ~datetime.datetime - :ivar updated_at: The exact time the message was 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. - :vartype accessed_at: ~datetime.datetime - :ivar size_in_bytes: The size of the queue, in bytes. - :vartype size_in_bytes: long - :ivar message_count: The number of messages in the queue. - :vartype message_count: long - :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. Default is 1024. - :type max_size_in_megabytes: int - :param requires_duplicate_detection: A value indicating if this queue requires duplicate - detection. - :type requires_duplicate_detection: bool - :param requires_session: A value that indicates whether the queue supports the concept of - sessions. - :type requires_session: bool - :param default_message_time_to_live: ISO 8601 default message timespan to live value. This is - the duration after which the message expires, starting from when the message is sent to Service - Bus. This is the default value used when TimeToLive is not set on a message itself. - :type default_message_time_to_live: ~datetime.timedelta - :param dead_lettering_on_message_expiration: A value that indicates whether this queue has dead - letter support when a message expires. - :type dead_lettering_on_message_expiration: bool - :param duplicate_detection_history_time_window: ISO 8601 timeSpan structure that defines the - duration of the duplicate detection history. The default value is 10 minutes. - :type duplicate_detection_history_time_window: ~datetime.timedelta - :param max_delivery_count: The maximum delivery count. A message is automatically deadlettered - after this number of deliveries. default value is 10. - :type max_delivery_count: int - :param status: Enumerates the possible values for the status of a messaging entity. Possible - values include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", - "Creating", "Deleting", "Renaming", "Unknown". - :type status: str or ~azure.mgmt.servicebus.v2017_04_01.models.EntityStatus - :param enable_batched_operations: Value that indicates whether server-side batched operations - are enabled. - :type enable_batched_operations: bool - :param auto_delete_on_idle: ISO 8061 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 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_to: Queue/Topic name to forward the messages. - :type forward_to: str - :param forward_dead_lettered_messages_to: Queue/Topic name to forward the Dead Letter message. - :type forward_dead_lettered_messages_to: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'count_details': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'accessed_at': {'readonly': True}, - 'size_in_bytes': {'readonly': True}, - 'message_count': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'size_in_bytes': {'key': 'properties.sizeInBytes', 'type': 'long'}, - 'message_count': {'key': 'properties.messageCount', 'type': 'long'}, - 'lock_duration': {'key': 'properties.lockDuration', 'type': 'duration'}, - 'max_size_in_megabytes': {'key': 'properties.maxSizeInMegabytes', 'type': 'int'}, - 'requires_duplicate_detection': {'key': 'properties.requiresDuplicateDetection', 'type': 'bool'}, - 'requires_session': {'key': 'properties.requiresSession', 'type': 'bool'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'duration'}, - 'dead_lettering_on_message_expiration': {'key': 'properties.deadLetteringOnMessageExpiration', 'type': 'bool'}, - 'duplicate_detection_history_time_window': {'key': 'properties.duplicateDetectionHistoryTimeWindow', 'type': 'duration'}, - 'max_delivery_count': {'key': 'properties.maxDeliveryCount', 'type': 'int'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'duration'}, - 'enable_partitioning': {'key': 'properties.enablePartitioning', 'type': 'bool'}, - 'enable_express': {'key': 'properties.enableExpress', 'type': 'bool'}, - 'forward_to': {'key': 'properties.forwardTo', 'type': 'str'}, - 'forward_dead_lettered_messages_to': {'key': 'properties.forwardDeadLetteredMessagesTo', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SBQueue, self).__init__(**kwargs) - self.count_details = None - self.created_at = None - self.updated_at = None - self.accessed_at = None - self.size_in_bytes = None - self.message_count = None - 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.status = kwargs.get('status', None) - self.enable_batched_operations = kwargs.get('enable_batched_operations', None) - self.auto_delete_on_idle = kwargs.get('auto_delete_on_idle', None) - self.enable_partitioning = kwargs.get('enable_partitioning', None) - self.enable_express = kwargs.get('enable_express', None) - self.forward_to = kwargs.get('forward_to', None) - self.forward_dead_lettered_messages_to = kwargs.get('forward_dead_lettered_messages_to', None) - - -class SBQueueListResult(msrest.serialization.Model): - """The response to the List Queues operation. - - :param value: Result of the List Queues operation. - :type value: list[~azure.mgmt.servicebus.v2017_04_01.models.SBQueue] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list - of queues. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SBQueue]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SBQueueListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class SBSku(msrest.serialization.Model): - """SKU of the namespace. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. Name of this SKU. Possible values include: "Basic", "Standard", - "Premium". - :type name: str or ~azure.mgmt.servicebus.v2017_04_01.models.SkuName - :param tier: The billing tier of this particular SKU. Possible values include: "Basic", - "Standard", "Premium". - :type tier: str or ~azure.mgmt.servicebus.v2017_04_01.models.SkuTier - :param capacity: The specified messaging units for the tier. For Premium tier, capacity are 1,2 - and 4. - :type capacity: int - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(SBSku, self).__init__(**kwargs) - self.name = kwargs['name'] - self.tier = kwargs.get('tier', None) - self.capacity = kwargs.get('capacity', None) - - -class SBSubscription(Resource): - """Description of subscription resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar message_count: Number of messages. - :vartype message_count: long - :ivar created_at: Exact time the message was created. - :vartype created_at: ~datetime.datetime - :ivar accessed_at: Last time there was a receive request to this subscription. - :vartype accessed_at: ~datetime.datetime - :ivar updated_at: The exact time the message was updated. - :vartype updated_at: ~datetime.datetime - :ivar count_details: Message count details. - :vartype count_details: ~azure.mgmt.servicebus.v2017_04_01.models.MessageCountDetails - :param lock_duration: ISO 8061 lock duration timespan for the subscription. The default value - is 1 minute. - :type lock_duration: ~datetime.timedelta - :param requires_session: Value indicating if a subscription supports the concept of sessions. - :type requires_session: bool - :param default_message_time_to_live: ISO 8061 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_filter_evaluation_exceptions: Value that indicates whether a - subscription has dead letter support on filter evaluation exceptions. - :type dead_lettering_on_filter_evaluation_exceptions: bool - :param dead_lettering_on_message_expiration: Value that indicates whether a subscription 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: Number of maximum deliveries. - :type max_delivery_count: int - :param status: Enumerates the possible values for the status of a messaging entity. Possible - values include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", - "Creating", "Deleting", "Renaming", "Unknown". - :type status: str or ~azure.mgmt.servicebus.v2017_04_01.models.EntityStatus - :param enable_batched_operations: Value that indicates whether server-side batched operations - are enabled. - :type enable_batched_operations: bool - :param auto_delete_on_idle: ISO 8061 timeSpan idle interval after which the topic is - automatically deleted. The minimum duration is 5 minutes. - :type auto_delete_on_idle: ~datetime.timedelta - :param forward_to: Queue/Topic name to forward the messages. - :type forward_to: str - :param forward_dead_lettered_messages_to: Queue/Topic name to forward the Dead Letter message. - :type forward_dead_lettered_messages_to: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'message_count': {'readonly': True}, - 'created_at': {'readonly': True}, - 'accessed_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'count_details': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'message_count': {'key': 'properties.messageCount', 'type': 'long'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'lock_duration': {'key': 'properties.lockDuration', 'type': 'duration'}, - 'requires_session': {'key': 'properties.requiresSession', 'type': 'bool'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'duration'}, - 'dead_lettering_on_filter_evaluation_exceptions': {'key': 'properties.deadLetteringOnFilterEvaluationExceptions', 'type': 'bool'}, - 'dead_lettering_on_message_expiration': {'key': 'properties.deadLetteringOnMessageExpiration', 'type': 'bool'}, - 'duplicate_detection_history_time_window': {'key': 'properties.duplicateDetectionHistoryTimeWindow', 'type': 'duration'}, - 'max_delivery_count': {'key': 'properties.maxDeliveryCount', 'type': 'int'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'duration'}, - 'forward_to': {'key': 'properties.forwardTo', 'type': 'str'}, - 'forward_dead_lettered_messages_to': {'key': 'properties.forwardDeadLetteredMessagesTo', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SBSubscription, self).__init__(**kwargs) - self.message_count = None - self.created_at = None - self.accessed_at = None - self.updated_at = None - self.count_details = None - self.lock_duration = kwargs.get('lock_duration', None) - self.requires_session = kwargs.get('requires_session', None) - self.default_message_time_to_live = kwargs.get('default_message_time_to_live', None) - self.dead_lettering_on_filter_evaluation_exceptions = kwargs.get('dead_lettering_on_filter_evaluation_exceptions', 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.status = kwargs.get('status', None) - self.enable_batched_operations = kwargs.get('enable_batched_operations', None) - self.auto_delete_on_idle = kwargs.get('auto_delete_on_idle', None) - self.forward_to = kwargs.get('forward_to', None) - self.forward_dead_lettered_messages_to = kwargs.get('forward_dead_lettered_messages_to', None) - - -class SBSubscriptionListResult(msrest.serialization.Model): - """The response to the List Subscriptions operation. - - :param value: Result of the List Subscriptions operation. - :type value: list[~azure.mgmt.servicebus.v2017_04_01.models.SBSubscription] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list - of subscriptions. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SBSubscription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SBSubscriptionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class SBTopic(Resource): - """Description of topic resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar size_in_bytes: Size of the topic, in bytes. - :vartype size_in_bytes: long - :ivar created_at: Exact time the message was created. - :vartype created_at: ~datetime.datetime - :ivar updated_at: The exact time the message was updated. - :vartype updated_at: ~datetime.datetime - :ivar accessed_at: Last time the message was sent, or a request was received, for this topic. - :vartype accessed_at: ~datetime.datetime - :ivar subscription_count: Number of subscriptions. - :vartype subscription_count: int - :ivar count_details: Message count details. - :vartype count_details: ~azure.mgmt.servicebus.v2017_04_01.models.MessageCountDetails - :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: Maximum size of the topic in megabytes, which is the size of the - memory allocated for the topic. Default is 1024. - :type max_size_in_megabytes: int - :param requires_duplicate_detection: Value indicating if this topic requires duplicate - detection. - :type requires_duplicate_detection: bool - :param duplicate_detection_history_time_window: ISO8601 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 status: Enumerates the possible values for the status of a messaging entity. Possible - values include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", - "Creating", "Deleting", "Renaming", "Unknown". - :type status: str or ~azure.mgmt.servicebus.v2017_04_01.models.EntityStatus - :param support_ordering: Value that indicates whether the topic supports ordering. - :type support_ordering: bool - :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: Value that indicates whether the topic to be partitioned across - multiple message brokers is enabled. - :type enable_partitioning: bool - :param enable_express: 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 - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'size_in_bytes': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'accessed_at': {'readonly': True}, - 'subscription_count': {'readonly': True}, - 'count_details': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'size_in_bytes': {'key': 'properties.sizeInBytes', 'type': 'long'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'subscription_count': {'key': 'properties.subscriptionCount', 'type': 'int'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'duration'}, - 'max_size_in_megabytes': {'key': 'properties.maxSizeInMegabytes', 'type': 'int'}, - 'requires_duplicate_detection': {'key': 'properties.requiresDuplicateDetection', 'type': 'bool'}, - 'duplicate_detection_history_time_window': {'key': 'properties.duplicateDetectionHistoryTimeWindow', 'type': 'duration'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'support_ordering': {'key': 'properties.supportOrdering', 'type': 'bool'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'duration'}, - 'enable_partitioning': {'key': 'properties.enablePartitioning', 'type': 'bool'}, - 'enable_express': {'key': 'properties.enableExpress', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(SBTopic, self).__init__(**kwargs) - self.size_in_bytes = None - self.created_at = None - self.updated_at = None - self.accessed_at = None - self.subscription_count = None - self.count_details = None - self.default_message_time_to_live = kwargs.get('default_message_time_to_live', None) - self.max_size_in_megabytes = kwargs.get('max_size_in_megabytes', None) - self.requires_duplicate_detection = kwargs.get('requires_duplicate_detection', None) - self.duplicate_detection_history_time_window = kwargs.get('duplicate_detection_history_time_window', None) - self.enable_batched_operations = kwargs.get('enable_batched_operations', None) - self.status = kwargs.get('status', None) - self.support_ordering = kwargs.get('support_ordering', None) - self.auto_delete_on_idle = kwargs.get('auto_delete_on_idle', None) - self.enable_partitioning = kwargs.get('enable_partitioning', None) - self.enable_express = kwargs.get('enable_express', None) - - -class SBTopicListResult(msrest.serialization.Model): - """The response to the List Topics operation. - - :param value: Result of the List Topics operation. - :type value: list[~azure.mgmt.servicebus.v2017_04_01.models.SBTopic] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list - of topics. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SBTopic]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SBTopicListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class SqlFilter(msrest.serialization.Model): - """Represents a filter which is a composition of an expression and an action that is executed in the pub/sub pipeline. - - :param sql_expression: The SQL expression. e.g. MyProperty='ABC'. - :type sql_expression: str - :param compatibility_level: This property is reserved for future use. An integer value showing - the compatibility level, currently hard-coded to 20. - :type compatibility_level: int - :param requires_preprocessing: Value that indicates whether the rule action requires - preprocessing. - :type requires_preprocessing: bool - """ - - _validation = { - 'compatibility_level': {'maximum': 20, 'minimum': 20}, - } - - _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(SqlFilter, self).__init__(**kwargs) - self.sql_expression = kwargs.get('sql_expression', None) - self.compatibility_level = kwargs.get('compatibility_level', 20) - self.requires_preprocessing = kwargs.get('requires_preprocessing', True) - - -class SqlRuleAction(Action): - """Represents set of actions written in SQL language-based syntax that is performed against a ServiceBus.Messaging.BrokeredMessage. - - :param sql_expression: SQL expression. e.g. MyProperty='ABC'. - :type sql_expression: str - :param compatibility_level: This property is reserved for future use. An integer value showing - the compatibility level, currently hard-coded to 20. - :type compatibility_level: int - :param requires_preprocessing: Value that indicates whether the rule action requires - preprocessing. - :type requires_preprocessing: bool - """ - - _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(SqlRuleAction, self).__init__(**kwargs) - - -class Subnet(msrest.serialization.Model): - """Properties supplied for Subnet. - - All required parameters must be populated in order to send to Azure. - - :param id: Required. Resource ID of Virtual Network Subnet. - :type id: str - """ - - _validation = { - 'id': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Subnet, self).__init__(**kwargs) - self.id = kwargs['id'] diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/models/_models_py3.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/models/_models_py3.py index cc7755aaf875..652077c121d9 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/models/_models_py3.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/models/_models_py3.py @@ -66,6 +66,8 @@ def __init__( self, **kwargs ): + """ + """ super(AccessKeys, self).__init__(**kwargs) self.primary_connection_string = None self.secondary_connection_string = None @@ -79,14 +81,14 @@ def __init__( class Action(msrest.serialization.Model): """Represents the filter actions which are allowed for the transformation of a message that have been matched by a filter expression. - :param sql_expression: SQL expression. e.g. MyProperty='ABC'. - :type sql_expression: str - :param compatibility_level: This property is reserved for future use. An integer value showing + :ivar sql_expression: SQL expression. e.g. MyProperty='ABC'. + :vartype sql_expression: str + :ivar compatibility_level: This property is reserved for future use. An integer value showing the compatibility level, currently hard-coded to 20. - :type compatibility_level: int - :param requires_preprocessing: Value that indicates whether the rule action requires + :vartype compatibility_level: int + :ivar requires_preprocessing: Value that indicates whether the rule action requires preprocessing. - :type requires_preprocessing: bool + :vartype requires_preprocessing: bool """ _attribute_map = { @@ -103,6 +105,16 @@ def __init__( requires_preprocessing: Optional[bool] = True, **kwargs ): + """ + :keyword sql_expression: SQL expression. e.g. MyProperty='ABC'. + :paramtype sql_expression: str + :keyword compatibility_level: This property is reserved for future use. An integer value + showing the compatibility level, currently hard-coded to 20. + :paramtype compatibility_level: int + :keyword requires_preprocessing: Value that indicates whether the rule action requires + preprocessing. + :paramtype requires_preprocessing: bool + """ super(Action, self).__init__(**kwargs) self.sql_expression = sql_expression self.compatibility_level = compatibility_level @@ -138,6 +150,8 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -162,12 +176,12 @@ class ArmDisasterRecovery(Resource): ~azure.mgmt.servicebus.v2017_04_01.models.ProvisioningStateDR :ivar pending_replication_operations_count: Number of entities pending to be replicated. :vartype pending_replication_operations_count: long - :param partner_namespace: ARM Id of the Primary/Secondary eventhub namespace name, which is - part of GEO DR pairing. - :type partner_namespace: str - :param alternate_name: Primary/Secondary eventhub namespace name, which is part of GEO DR + :ivar partner_namespace: ARM Id of the Primary/Secondary eventhub namespace name, which is part + of GEO DR pairing. + :vartype partner_namespace: str + :ivar alternate_name: Primary/Secondary eventhub namespace name, which is part of GEO DR pairing. - :type alternate_name: str + :vartype alternate_name: str :ivar role: role of namespace in GEO DR - possible values 'Primary' or 'PrimaryNotReplicating' or 'Secondary'. Possible values include: "Primary", "PrimaryNotReplicating", "Secondary". :vartype role: str or ~azure.mgmt.servicebus.v2017_04_01.models.RoleDisasterRecovery @@ -200,6 +214,14 @@ def __init__( alternate_name: Optional[str] = None, **kwargs ): + """ + :keyword partner_namespace: ARM Id of the Primary/Secondary eventhub namespace name, which is + part of GEO DR pairing. + :paramtype partner_namespace: str + :keyword alternate_name: Primary/Secondary eventhub namespace name, which is part of GEO DR + pairing. + :paramtype alternate_name: str + """ super(ArmDisasterRecovery, self).__init__(**kwargs) self.provisioning_state = None self.pending_replication_operations_count = None @@ -213,8 +235,8 @@ class ArmDisasterRecoveryListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: List of Alias(Disaster Recovery configurations). - :type value: list[~azure.mgmt.servicebus.v2017_04_01.models.ArmDisasterRecovery] + :ivar value: List of Alias(Disaster Recovery configurations). + :vartype value: list[~azure.mgmt.servicebus.v2017_04_01.models.ArmDisasterRecovery] :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of Alias(Disaster Recovery configuration). :vartype next_link: str @@ -235,6 +257,10 @@ def __init__( value: Optional[List["ArmDisasterRecovery"]] = None, **kwargs ): + """ + :keyword value: List of Alias(Disaster Recovery configurations). + :paramtype value: list[~azure.mgmt.servicebus.v2017_04_01.models.ArmDisasterRecovery] + """ super(ArmDisasterRecoveryListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -243,20 +269,20 @@ def __init__( class CaptureDescription(msrest.serialization.Model): """Properties to configure capture description for eventhub. - :param enabled: A value that indicates whether capture description is enabled. - :type enabled: bool - :param encoding: Enumerates the possible values for the encoding format of capture description. + :ivar enabled: A value that indicates whether capture description is enabled. + :vartype enabled: bool + :ivar encoding: Enumerates the possible values for the encoding format of capture description. Possible values include: "Avro", "AvroDeflate". - :type encoding: str or ~azure.mgmt.servicebus.v2017_04_01.models.EncodingCaptureDescription - :param interval_in_seconds: The time window allows you to set the frequency with which the + :vartype encoding: str or ~azure.mgmt.servicebus.v2017_04_01.models.EncodingCaptureDescription + :ivar interval_in_seconds: The time window allows you to set the frequency with which the capture to Azure Blobs will happen, value should between 60 to 900 seconds. - :type interval_in_seconds: int - :param size_limit_in_bytes: The size window defines the amount of data built up in your Event + :vartype interval_in_seconds: int + :ivar size_limit_in_bytes: The size window defines the amount of data built up in your Event Hub before an capture operation, value should be between 10485760 and 524288000 bytes. - :type size_limit_in_bytes: int - :param destination: Properties of Destination where capture will be stored. (Storage Account, + :vartype size_limit_in_bytes: int + :ivar destination: Properties of Destination where capture will be stored. (Storage Account, Blob Names). - :type destination: ~azure.mgmt.servicebus.v2017_04_01.models.Destination + :vartype destination: ~azure.mgmt.servicebus.v2017_04_01.models.Destination """ _validation = { @@ -282,6 +308,23 @@ def __init__( destination: Optional["Destination"] = None, **kwargs ): + """ + :keyword enabled: A value that indicates whether capture description is enabled. + :paramtype enabled: bool + :keyword encoding: Enumerates the possible values for the encoding format of capture + description. Possible values include: "Avro", "AvroDeflate". + :paramtype encoding: str or + ~azure.mgmt.servicebus.v2017_04_01.models.EncodingCaptureDescription + :keyword interval_in_seconds: The time window allows you to set the frequency with which the + capture to Azure Blobs will happen, value should between 60 to 900 seconds. + :paramtype interval_in_seconds: int + :keyword size_limit_in_bytes: The size window defines the amount of data built up in your Event + Hub before an capture operation, value should be between 10485760 and 524288000 bytes. + :paramtype size_limit_in_bytes: int + :keyword destination: Properties of Destination where capture will be stored. (Storage Account, + Blob Names). + :paramtype destination: ~azure.mgmt.servicebus.v2017_04_01.models.Destination + """ super(CaptureDescription, self).__init__(**kwargs) self.enabled = enabled self.encoding = encoding @@ -295,10 +338,10 @@ class CheckNameAvailability(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The Name to check the namespace name availability and The namespace name + :ivar name: Required. The Name to check the namespace name availability and The namespace name can contain only letters, numbers, and hyphens. The namespace must start with a letter, and it must end with a letter or number. - :type name: str + :vartype name: str """ _validation = { @@ -315,6 +358,12 @@ def __init__( name: str, **kwargs ): + """ + :keyword name: Required. The Name to check the namespace name availability and The namespace + name can contain only letters, numbers, and hyphens. The namespace must start with a letter, + and it must end with a letter or number. + :paramtype name: str + """ super(CheckNameAvailability, self).__init__(**kwargs) self.name = name @@ -326,13 +375,13 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): :ivar message: The detailed info regarding the reason associated with the namespace. :vartype message: str - :param name_available: Value indicating namespace is availability, true if the namespace is + :ivar name_available: Value indicating namespace is availability, true if the namespace is available; otherwise, false. - :type name_available: bool - :param reason: The reason for unavailability of a namespace. Possible values include: "None", + :vartype name_available: bool + :ivar reason: The reason for unavailability of a namespace. Possible values include: "None", "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", "TooManyNamespaceInCurrentSubscription". - :type reason: str or ~azure.mgmt.servicebus.v2017_04_01.models.UnavailableReason + :vartype reason: str or ~azure.mgmt.servicebus.v2017_04_01.models.UnavailableReason """ _validation = { @@ -352,6 +401,15 @@ def __init__( reason: Optional[Union[str, "UnavailableReason"]] = None, **kwargs ): + """ + :keyword name_available: Value indicating namespace is availability, true if the namespace is + available; otherwise, false. + :paramtype name_available: bool + :keyword reason: The reason for unavailability of a namespace. Possible values include: "None", + "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", + "TooManyNamespaceInCurrentSubscription". + :paramtype reason: str or ~azure.mgmt.servicebus.v2017_04_01.models.UnavailableReason + """ super(CheckNameAvailabilityResult, self).__init__(**kwargs) self.message = None self.name_available = name_available @@ -361,27 +419,27 @@ def __init__( class CorrelationFilter(msrest.serialization.Model): """Represents the correlation filter expression. - :param properties: dictionary object for custom filters. - :type properties: dict[str, str] - :param correlation_id: Identifier of the correlation. - :type correlation_id: str - :param message_id: Identifier of the message. - :type message_id: str - :param to: Address to send to. - :type to: str - :param reply_to: Address of the queue to reply to. - :type reply_to: str - :param label: Application specific label. - :type label: str - :param session_id: Session identifier. - :type session_id: str - :param reply_to_session_id: Session identifier to reply to. - :type reply_to_session_id: str - :param content_type: Content type of the message. - :type content_type: str - :param requires_preprocessing: Value that indicates whether the rule action requires + :ivar properties: dictionary object for custom filters. + :vartype properties: dict[str, str] + :ivar correlation_id: Identifier of the correlation. + :vartype correlation_id: str + :ivar message_id: Identifier of the message. + :vartype message_id: str + :ivar to: Address to send to. + :vartype to: str + :ivar reply_to: Address of the queue to reply to. + :vartype reply_to: str + :ivar label: Application specific label. + :vartype label: str + :ivar session_id: Session identifier. + :vartype session_id: str + :ivar reply_to_session_id: Session identifier to reply to. + :vartype reply_to_session_id: str + :ivar content_type: Content type of the message. + :vartype content_type: str + :ivar requires_preprocessing: Value that indicates whether the rule action requires preprocessing. - :type requires_preprocessing: bool + :vartype requires_preprocessing: bool """ _attribute_map = { @@ -412,6 +470,29 @@ def __init__( requires_preprocessing: Optional[bool] = True, **kwargs ): + """ + :keyword properties: dictionary object for custom filters. + :paramtype properties: dict[str, str] + :keyword correlation_id: Identifier of the correlation. + :paramtype correlation_id: str + :keyword message_id: Identifier of the message. + :paramtype message_id: str + :keyword to: Address to send to. + :paramtype to: str + :keyword reply_to: Address of the queue to reply to. + :paramtype reply_to: str + :keyword label: Application specific label. + :paramtype label: str + :keyword session_id: Session identifier. + :paramtype session_id: str + :keyword reply_to_session_id: Session identifier to reply to. + :paramtype reply_to_session_id: str + :keyword content_type: Content type of the message. + :paramtype content_type: str + :keyword requires_preprocessing: Value that indicates whether the rule action requires + preprocessing. + :paramtype requires_preprocessing: bool + """ super(CorrelationFilter, self).__init__(**kwargs) self.properties = properties self.correlation_id = correlation_id @@ -428,17 +509,17 @@ def __init__( class Destination(msrest.serialization.Model): """Capture storage details for capture description. - :param name: Name for capture destination. - :type name: str - :param storage_account_resource_id: Resource id of the storage account to be used to create the + :ivar name: Name for capture destination. + :vartype name: str + :ivar storage_account_resource_id: Resource id of the storage account to be used to create the blobs. - :type storage_account_resource_id: str - :param blob_container: Blob container Name. - :type blob_container: str - :param archive_name_format: Blob naming convention for archive, e.g. + :vartype storage_account_resource_id: str + :ivar blob_container: Blob container Name. + :vartype blob_container: str + :ivar archive_name_format: Blob naming convention for archive, e.g. {Namespace}/{EventHub}/{PartitionId}/{Year}/{Month}/{Day}/{Hour}/{Minute}/{Second}. Here all the parameters (Namespace,EventHub .. etc) are mandatory irrespective of order. - :type archive_name_format: str + :vartype archive_name_format: str """ _attribute_map = { @@ -457,6 +538,19 @@ def __init__( archive_name_format: Optional[str] = None, **kwargs ): + """ + :keyword name: Name for capture destination. + :paramtype name: str + :keyword storage_account_resource_id: Resource id of the storage account to be used to create + the blobs. + :paramtype storage_account_resource_id: str + :keyword blob_container: Blob container Name. + :paramtype blob_container: str + :keyword archive_name_format: Blob naming convention for archive, e.g. + {Namespace}/{EventHub}/{PartitionId}/{Year}/{Month}/{Day}/{Hour}/{Minute}/{Second}. Here all + the parameters (Namespace,EventHub .. etc) are mandatory irrespective of order. + :paramtype archive_name_format: str + """ super(Destination, self).__init__(**kwargs) self.name = name self.storage_account_resource_id = storage_account_resource_id @@ -489,6 +583,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -497,8 +593,8 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """The resource management error response. - :param error: The error object. - :type error: ~azure.mgmt.servicebus.v2017_04_01.models.ErrorResponseError + :ivar error: The error object. + :vartype error: ~azure.mgmt.servicebus.v2017_04_01.models.ErrorResponseError """ _attribute_map = { @@ -511,6 +607,10 @@ def __init__( error: Optional["ErrorResponseError"] = None, **kwargs ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.servicebus.v2017_04_01.models.ErrorResponseError + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -552,6 +652,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponseError, self).__init__(**kwargs) self.code = None self.message = None @@ -577,18 +679,18 @@ class Eventhub(Resource): :vartype created_at: ~datetime.datetime :ivar updated_at: The exact time the message was updated. :vartype updated_at: ~datetime.datetime - :param message_retention_in_days: Number of days to retain the events for this Event Hub, value + :ivar message_retention_in_days: Number of days to retain the events for this Event Hub, value should be 1 to 7 days. - :type message_retention_in_days: long - :param partition_count: Number of partitions created for the Event Hub, allowed values are from + :vartype message_retention_in_days: long + :ivar partition_count: Number of partitions created for the Event Hub, allowed values are from 1 to 32 partitions. - :type partition_count: long - :param status: Enumerates the possible values for the status of a Event Hub. Possible values + :vartype partition_count: long + :ivar status: Enumerates the possible values for the status of a Event Hub. Possible values include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", "Deleting", "Renaming", "Unknown". - :type status: str or ~azure.mgmt.servicebus.v2017_04_01.models.EntityStatus - :param capture_description: Properties of capture description. - :type capture_description: ~azure.mgmt.servicebus.v2017_04_01.models.CaptureDescription + :vartype status: str or ~azure.mgmt.servicebus.v2017_04_01.models.EntityStatus + :ivar capture_description: Properties of capture description. + :vartype capture_description: ~azure.mgmt.servicebus.v2017_04_01.models.CaptureDescription """ _validation = { @@ -624,6 +726,20 @@ def __init__( capture_description: Optional["CaptureDescription"] = None, **kwargs ): + """ + :keyword message_retention_in_days: Number of days to retain the events for this Event Hub, + value should be 1 to 7 days. + :paramtype message_retention_in_days: long + :keyword partition_count: Number of partitions created for the Event Hub, allowed values are + from 1 to 32 partitions. + :paramtype partition_count: long + :keyword status: Enumerates the possible values for the status of a Event Hub. Possible values + include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", + "Deleting", "Renaming", "Unknown". + :paramtype status: str or ~azure.mgmt.servicebus.v2017_04_01.models.EntityStatus + :keyword capture_description: Properties of capture description. + :paramtype capture_description: ~azure.mgmt.servicebus.v2017_04_01.models.CaptureDescription + """ super(Eventhub, self).__init__(**kwargs) self.partition_ids = None self.created_at = None @@ -639,8 +755,8 @@ class EventHubListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: Result of the List EventHubs operation. - :type value: list[~azure.mgmt.servicebus.v2017_04_01.models.Eventhub] + :ivar value: Result of the List EventHubs operation. + :vartype value: list[~azure.mgmt.servicebus.v2017_04_01.models.Eventhub] :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of EventHubs. :vartype next_link: str @@ -661,6 +777,10 @@ def __init__( value: Optional[List["Eventhub"]] = None, **kwargs ): + """ + :keyword value: Result of the List EventHubs operation. + :paramtype value: list[~azure.mgmt.servicebus.v2017_04_01.models.Eventhub] + """ super(EventHubListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -704,6 +824,8 @@ def __init__( self, **kwargs ): + """ + """ super(MessageCountDetails, self).__init__(**kwargs) self.active_message_count = None self.dead_letter_message_count = None @@ -717,8 +839,8 @@ class MigrationConfigListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: List of Migration Configs. - :type value: list[~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigProperties] + :ivar value: List of Migration Configs. + :vartype value: list[~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigProperties] :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of migrationConfigurations. :vartype next_link: str @@ -739,6 +861,10 @@ def __init__( value: Optional[List["MigrationConfigProperties"]] = None, **kwargs ): + """ + :keyword value: List of Migration Configs. + :paramtype value: list[~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigProperties] + """ super(MigrationConfigListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -759,11 +885,11 @@ class MigrationConfigProperties(Resource): :vartype provisioning_state: str :ivar pending_replication_operations_count: Number of entities pending to be replicated. :vartype pending_replication_operations_count: long - :param target_namespace: Existing premium Namespace ARM Id name which has no entities, will be + :ivar target_namespace: Existing premium Namespace ARM Id name which has no entities, will be used for migration. - :type target_namespace: str - :param post_migration_name: Name to access Standard Namespace after migration. - :type post_migration_name: str + :vartype target_namespace: str + :ivar post_migration_name: Name to access Standard Namespace after migration. + :vartype post_migration_name: str :ivar migration_state: State in which Standard to Premium Migration is, possible values : Unknown, Reverting, Completing, Initiating, Syncing, Active. :vartype migration_state: str @@ -796,6 +922,13 @@ def __init__( post_migration_name: Optional[str] = None, **kwargs ): + """ + :keyword target_namespace: Existing premium Namespace ARM Id name which has no entities, will + be used for migration. + :paramtype target_namespace: str + :keyword post_migration_name: Name to access Standard Namespace after migration. + :paramtype post_migration_name: str + """ super(MigrationConfigProperties, self).__init__(**kwargs) self.provisioning_state = None self.pending_replication_operations_count = None @@ -815,14 +948,14 @@ class NetworkRuleSet(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param default_action: Default Action for Network Rule Set. Possible values include: "Allow", + :ivar default_action: Default Action for Network Rule Set. Possible values include: "Allow", "Deny". - :type default_action: str or ~azure.mgmt.servicebus.v2017_04_01.models.DefaultAction - :param virtual_network_rules: List VirtualNetwork Rules. - :type virtual_network_rules: + :vartype default_action: str or ~azure.mgmt.servicebus.v2017_04_01.models.DefaultAction + :ivar virtual_network_rules: List VirtualNetwork Rules. + :vartype virtual_network_rules: list[~azure.mgmt.servicebus.v2017_04_01.models.NWRuleSetVirtualNetworkRules] - :param ip_rules: List of IpRules. - :type ip_rules: list[~azure.mgmt.servicebus.v2017_04_01.models.NWRuleSetIpRules] + :ivar ip_rules: List of IpRules. + :vartype ip_rules: list[~azure.mgmt.servicebus.v2017_04_01.models.NWRuleSetIpRules] """ _validation = { @@ -848,6 +981,16 @@ def __init__( ip_rules: Optional[List["NWRuleSetIpRules"]] = None, **kwargs ): + """ + :keyword default_action: Default Action for Network Rule Set. Possible values include: "Allow", + "Deny". + :paramtype default_action: str or ~azure.mgmt.servicebus.v2017_04_01.models.DefaultAction + :keyword virtual_network_rules: List VirtualNetwork Rules. + :paramtype virtual_network_rules: + list[~azure.mgmt.servicebus.v2017_04_01.models.NWRuleSetVirtualNetworkRules] + :keyword ip_rules: List of IpRules. + :paramtype ip_rules: list[~azure.mgmt.servicebus.v2017_04_01.models.NWRuleSetIpRules] + """ super(NetworkRuleSet, self).__init__(**kwargs) self.default_action = default_action self.virtual_network_rules = virtual_network_rules @@ -857,11 +1000,11 @@ def __init__( class NetworkRuleSetListResult(msrest.serialization.Model): """The response of the List NetworkRuleSet operation. - :param value: Result of the List NetworkRuleSet operation. - :type value: list[~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleSet] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list + :ivar value: Result of the List NetworkRuleSet operation. + :vartype value: list[~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleSet] + :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of NetworkRuleSet. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -876,6 +1019,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of the List NetworkRuleSet operation. + :paramtype value: list[~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleSet] + :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete + list of NetworkRuleSet. + :paramtype next_link: str + """ super(NetworkRuleSetListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -884,10 +1034,10 @@ def __init__( class NWRuleSetIpRules(msrest.serialization.Model): """Description of NetWorkRuleSet - IpRules resource. - :param ip_mask: IP Mask. - :type ip_mask: str - :param action: The IP Filter Action. Possible values include: "Allow". Default value: "Allow". - :type action: str or ~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleIPAction + :ivar ip_mask: IP Mask. + :vartype ip_mask: str + :ivar action: The IP Filter Action. Possible values include: "Allow". Default value: "Allow". + :vartype action: str or ~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleIPAction """ _attribute_map = { @@ -902,6 +1052,13 @@ def __init__( action: Optional[Union[str, "NetworkRuleIPAction"]] = "Allow", **kwargs ): + """ + :keyword ip_mask: IP Mask. + :paramtype ip_mask: str + :keyword action: The IP Filter Action. Possible values include: "Allow". Default value: + "Allow". + :paramtype action: str or ~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleIPAction + """ super(NWRuleSetIpRules, self).__init__(**kwargs) self.ip_mask = ip_mask self.action = action @@ -910,11 +1067,11 @@ def __init__( class NWRuleSetVirtualNetworkRules(msrest.serialization.Model): """Description of VirtualNetworkRules - NetworkRules resource. - :param subnet: Subnet properties. - :type subnet: ~azure.mgmt.servicebus.v2017_04_01.models.Subnet - :param ignore_missing_vnet_service_endpoint: Value that indicates whether to ignore missing - VNet Service Endpoint. - :type ignore_missing_vnet_service_endpoint: bool + :ivar subnet: Subnet properties. + :vartype subnet: ~azure.mgmt.servicebus.v2017_04_01.models.Subnet + :ivar ignore_missing_vnet_service_endpoint: Value that indicates whether to ignore missing VNet + Service Endpoint. + :vartype ignore_missing_vnet_service_endpoint: bool """ _attribute_map = { @@ -929,6 +1086,13 @@ def __init__( ignore_missing_vnet_service_endpoint: Optional[bool] = None, **kwargs ): + """ + :keyword subnet: Subnet properties. + :paramtype subnet: ~azure.mgmt.servicebus.v2017_04_01.models.Subnet + :keyword ignore_missing_vnet_service_endpoint: Value that indicates whether to ignore missing + VNet Service Endpoint. + :paramtype ignore_missing_vnet_service_endpoint: bool + """ super(NWRuleSetVirtualNetworkRules, self).__init__(**kwargs) self.subnet = subnet self.ignore_missing_vnet_service_endpoint = ignore_missing_vnet_service_endpoint @@ -941,8 +1105,8 @@ class Operation(msrest.serialization.Model): :ivar name: Operation name: {provider}/{resource}/{operation}. :vartype name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.servicebus.v2017_04_01.models.OperationDisplay + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.servicebus.v2017_04_01.models.OperationDisplay """ _validation = { @@ -960,6 +1124,10 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.servicebus.v2017_04_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = None self.display = display @@ -994,6 +1162,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = None self.resource = None @@ -1026,6 +1196,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -1042,10 +1214,10 @@ class ResourceNamespacePatch(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -1069,6 +1241,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(ResourceNamespacePatch, self).__init__(**kwargs) self.location = location self.tags = tags @@ -1085,12 +1263,13 @@ class PremiumMessagingRegions(ResourceNamespacePatch): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param properties: - :type properties: ~azure.mgmt.servicebus.v2017_04_01.models.PremiumMessagingRegionsProperties + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar properties: + :vartype properties: + ~azure.mgmt.servicebus.v2017_04_01.models.PremiumMessagingRegionsProperties """ _validation = { @@ -1116,6 +1295,15 @@ def __init__( properties: Optional["PremiumMessagingRegionsProperties"] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword properties: + :paramtype properties: + ~azure.mgmt.servicebus.v2017_04_01.models.PremiumMessagingRegionsProperties + """ super(PremiumMessagingRegions, self).__init__(location=location, tags=tags, **kwargs) self.properties = properties @@ -1125,8 +1313,8 @@ class PremiumMessagingRegionsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: Result of the List PremiumMessagingRegions type. - :type value: list[~azure.mgmt.servicebus.v2017_04_01.models.PremiumMessagingRegions] + :ivar value: Result of the List PremiumMessagingRegions type. + :vartype value: list[~azure.mgmt.servicebus.v2017_04_01.models.PremiumMessagingRegions] :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of PremiumMessagingRegions. :vartype next_link: str @@ -1147,6 +1335,10 @@ def __init__( value: Optional[List["PremiumMessagingRegions"]] = None, **kwargs ): + """ + :keyword value: Result of the List PremiumMessagingRegions type. + :paramtype value: list[~azure.mgmt.servicebus.v2017_04_01.models.PremiumMessagingRegions] + """ super(PremiumMessagingRegionsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1177,6 +1369,8 @@ def __init__( self, **kwargs ): + """ + """ super(PremiumMessagingRegionsProperties, self).__init__(**kwargs) self.code = None self.full_name = None @@ -1187,12 +1381,12 @@ class RegenerateAccessKeyParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param key_type: Required. The access key to regenerate. Possible values include: "PrimaryKey", + :ivar key_type: Required. The access key to regenerate. Possible values include: "PrimaryKey", "SecondaryKey". - :type key_type: str or ~azure.mgmt.servicebus.v2017_04_01.models.KeyType - :param key: Optional, if the key value provided, is reset for KeyType value or autogenerate Key + :vartype key_type: str or ~azure.mgmt.servicebus.v2017_04_01.models.KeyType + :ivar key: Optional, if the key value provided, is reset for KeyType value or autogenerate Key value set for keyType. - :type key: str + :vartype key: str """ _validation = { @@ -1211,6 +1405,14 @@ def __init__( key: Optional[str] = None, **kwargs ): + """ + :keyword key_type: Required. The access key to regenerate. Possible values include: + "PrimaryKey", "SecondaryKey". + :paramtype key_type: str or ~azure.mgmt.servicebus.v2017_04_01.models.KeyType + :keyword key: Optional, if the key value provided, is reset for KeyType value or autogenerate + Key value set for keyType. + :paramtype key: str + """ super(RegenerateAccessKeyParameters, self).__init__(**kwargs) self.key_type = key_type self.key = key @@ -1227,16 +1429,16 @@ class Rule(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param action: Represents the filter actions which are allowed for the transformation of a + :ivar action: Represents the filter actions which are allowed for the transformation of a message that have been matched by a filter expression. - :type action: ~azure.mgmt.servicebus.v2017_04_01.models.Action - :param filter_type: Filter type that is evaluated against a BrokeredMessage. Possible values + :vartype action: ~azure.mgmt.servicebus.v2017_04_01.models.Action + :ivar filter_type: Filter type that is evaluated against a BrokeredMessage. Possible values include: "SqlFilter", "CorrelationFilter". - :type filter_type: str or ~azure.mgmt.servicebus.v2017_04_01.models.FilterType - :param sql_filter: Properties of sqlFilter. - :type sql_filter: ~azure.mgmt.servicebus.v2017_04_01.models.SqlFilter - :param correlation_filter: Properties of correlationFilter. - :type correlation_filter: ~azure.mgmt.servicebus.v2017_04_01.models.CorrelationFilter + :vartype filter_type: str or ~azure.mgmt.servicebus.v2017_04_01.models.FilterType + :ivar sql_filter: Properties of sqlFilter. + :vartype sql_filter: ~azure.mgmt.servicebus.v2017_04_01.models.SqlFilter + :ivar correlation_filter: Properties of correlationFilter. + :vartype correlation_filter: ~azure.mgmt.servicebus.v2017_04_01.models.CorrelationFilter """ _validation = { @@ -1264,6 +1466,18 @@ def __init__( correlation_filter: Optional["CorrelationFilter"] = None, **kwargs ): + """ + :keyword action: Represents the filter actions which are allowed for the transformation of a + message that have been matched by a filter expression. + :paramtype action: ~azure.mgmt.servicebus.v2017_04_01.models.Action + :keyword filter_type: Filter type that is evaluated against a BrokeredMessage. Possible values + include: "SqlFilter", "CorrelationFilter". + :paramtype filter_type: str or ~azure.mgmt.servicebus.v2017_04_01.models.FilterType + :keyword sql_filter: Properties of sqlFilter. + :paramtype sql_filter: ~azure.mgmt.servicebus.v2017_04_01.models.SqlFilter + :keyword correlation_filter: Properties of correlationFilter. + :paramtype correlation_filter: ~azure.mgmt.servicebus.v2017_04_01.models.CorrelationFilter + """ super(Rule, self).__init__(**kwargs) self.action = action self.filter_type = filter_type @@ -1274,11 +1488,11 @@ def __init__( class RuleListResult(msrest.serialization.Model): """The response of the List rule operation. - :param value: Result of the List Rules operation. - :type value: list[~azure.mgmt.servicebus.v2017_04_01.models.Rule] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list + :ivar value: Result of the List Rules operation. + :vartype value: list[~azure.mgmt.servicebus.v2017_04_01.models.Rule] + :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of rules. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -1293,6 +1507,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of the List Rules operation. + :paramtype value: list[~azure.mgmt.servicebus.v2017_04_01.models.Rule] + :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete + list of rules. + :paramtype next_link: str + """ super(RuleListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1309,8 +1530,8 @@ class SBAuthorizationRule(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param rights: The rights associated with the rule. - :type rights: list[str or ~azure.mgmt.servicebus.v2017_04_01.models.AccessRights] + :ivar rights: The rights associated with the rule. + :vartype rights: list[str or ~azure.mgmt.servicebus.v2017_04_01.models.AccessRights] """ _validation = { @@ -1332,6 +1553,10 @@ def __init__( rights: Optional[List[Union[str, "AccessRights"]]] = None, **kwargs ): + """ + :keyword rights: The rights associated with the rule. + :paramtype rights: list[str or ~azure.mgmt.servicebus.v2017_04_01.models.AccessRights] + """ super(SBAuthorizationRule, self).__init__(**kwargs) self.rights = rights @@ -1339,11 +1564,11 @@ def __init__( class SBAuthorizationRuleListResult(msrest.serialization.Model): """The response to the List Namespace operation. - :param value: Result of the List Authorization Rules operation. - :type value: list[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list + :ivar value: Result of the List Authorization Rules operation. + :vartype value: list[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule] + :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of Authorization Rules. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -1358,6 +1583,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of the List Authorization Rules operation. + :paramtype value: list[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule] + :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete + list of Authorization Rules. + :paramtype next_link: str + """ super(SBAuthorizationRuleListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1376,10 +1608,10 @@ class TrackedResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Required. The Geo-location where the resource lives. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Required. The Geo-location where the resource lives. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -1404,6 +1636,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. The Geo-location where the resource lives. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(TrackedResource, self).__init__(**kwargs) self.location = location self.tags = tags @@ -1422,12 +1660,12 @@ class SBNamespace(TrackedResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Required. The Geo-location where the resource lives. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param sku: Properties of Sku. - :type sku: ~azure.mgmt.servicebus.v2017_04_01.models.SBSku + :ivar location: Required. The Geo-location where the resource lives. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar sku: Properties of Sku. + :vartype sku: ~azure.mgmt.servicebus.v2017_04_01.models.SBSku :ivar provisioning_state: Provisioning state of the namespace. :vartype provisioning_state: str :ivar created_at: The time the namespace was created. @@ -1474,6 +1712,14 @@ def __init__( sku: Optional["SBSku"] = None, **kwargs ): + """ + :keyword location: Required. The Geo-location where the resource lives. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword sku: Properties of Sku. + :paramtype sku: ~azure.mgmt.servicebus.v2017_04_01.models.SBSku + """ super(SBNamespace, self).__init__(location=location, tags=tags, **kwargs) self.sku = sku self.provisioning_state = None @@ -1486,11 +1732,11 @@ def __init__( class SBNamespaceListResult(msrest.serialization.Model): """The response of the List Namespace operation. - :param value: Result of the List Namespace operation. - :type value: list[~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list + :ivar value: Result of the List Namespace operation. + :vartype value: list[~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace] + :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of Namespaces. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -1505,6 +1751,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of the List Namespace operation. + :paramtype value: list[~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace] + :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete + list of Namespaces. + :paramtype next_link: str + """ super(SBNamespaceListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1515,9 +1768,9 @@ class SBNamespaceMigrate(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param target_namespace_type: Required. Type of namespaces. Possible values include: + :ivar target_namespace_type: Required. Type of namespaces. Possible values include: "Messaging", "NotificationHub", "Mixed", "EventHub", "Relay". - :type target_namespace_type: str or ~azure.mgmt.servicebus.v2017_04_01.models.NameSpaceType + :vartype target_namespace_type: str or ~azure.mgmt.servicebus.v2017_04_01.models.NameSpaceType """ _validation = { @@ -1534,6 +1787,12 @@ def __init__( target_namespace_type: Union[str, "NameSpaceType"], **kwargs ): + """ + :keyword target_namespace_type: Required. Type of namespaces. Possible values include: + "Messaging", "NotificationHub", "Mixed", "EventHub", "Relay". + :paramtype target_namespace_type: str or + ~azure.mgmt.servicebus.v2017_04_01.models.NameSpaceType + """ super(SBNamespaceMigrate, self).__init__(**kwargs) self.target_namespace_type = target_namespace_type @@ -1549,12 +1808,12 @@ class SBNamespaceUpdateParameters(ResourceNamespacePatch): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param sku: Properties of Sku. - :type sku: ~azure.mgmt.servicebus.v2017_04_01.models.SBSku + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar sku: Properties of Sku. + :vartype sku: ~azure.mgmt.servicebus.v2017_04_01.models.SBSku :ivar provisioning_state: Provisioning state of the namespace. :vartype provisioning_state: str :ivar created_at: The time the namespace was created. @@ -1600,6 +1859,14 @@ def __init__( sku: Optional["SBSku"] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword sku: Properties of Sku. + :paramtype sku: ~azure.mgmt.servicebus.v2017_04_01.models.SBSku + """ super(SBNamespaceUpdateParameters, self).__init__(location=location, tags=tags, **kwargs) self.sku = sku self.provisioning_state = None @@ -1633,52 +1900,52 @@ class SBQueue(Resource): :vartype size_in_bytes: long :ivar message_count: The number of messages in the queue. :vartype message_count: long - :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. Default is 1024. - :type max_size_in_megabytes: int - :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 status: Enumerates the possible values for the status of a messaging entity. Possible + :vartype max_delivery_count: int + :ivar status: Enumerates the possible values for the status of a messaging entity. Possible values include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", "Deleting", "Renaming", "Unknown". - :type status: str or ~azure.mgmt.servicebus.v2017_04_01.models.EntityStatus - :param enable_batched_operations: Value that indicates whether server-side batched operations + :vartype status: str or ~azure.mgmt.servicebus.v2017_04_01.models.EntityStatus + :ivar enable_batched_operations: Value that indicates whether server-side batched operations are enabled. - :type enable_batched_operations: bool - :param auto_delete_on_idle: ISO 8061 timeSpan idle interval after which the queue is + :vartype enable_batched_operations: bool + :ivar auto_delete_on_idle: ISO 8061 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 enable_express: A value that indicates whether Express Entities are enabled. An express + :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 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_to: Queue/Topic name to forward the messages. - :type forward_to: str - :param forward_dead_lettered_messages_to: Queue/Topic name to forward the Dead Letter message. - :type forward_dead_lettered_messages_to: str + :vartype enable_express: bool + :ivar forward_to: Queue/Topic name to forward the messages. + :vartype forward_to: str + :ivar forward_dead_lettered_messages_to: Queue/Topic name to forward the Dead Letter message. + :vartype forward_dead_lettered_messages_to: str """ _validation = { @@ -1740,6 +2007,55 @@ def __init__( forward_dead_lettered_messages_to: Optional[str] = None, **kwargs ): + """ + :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. Default is 1024. + :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 status: Enumerates the possible values for the status of a messaging entity. Possible + values include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", + "Creating", "Deleting", "Renaming", "Unknown". + :paramtype status: str or ~azure.mgmt.servicebus.v2017_04_01.models.EntityStatus + :keyword enable_batched_operations: Value that indicates whether server-side batched operations + are enabled. + :paramtype enable_batched_operations: bool + :keyword auto_delete_on_idle: ISO 8061 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 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_to: Queue/Topic name to forward the messages. + :paramtype forward_to: str + :keyword forward_dead_lettered_messages_to: Queue/Topic name to forward the Dead Letter + message. + :paramtype forward_dead_lettered_messages_to: str + """ super(SBQueue, self).__init__(**kwargs) self.count_details = None self.created_at = None @@ -1767,11 +2083,11 @@ def __init__( class SBQueueListResult(msrest.serialization.Model): """The response to the List Queues operation. - :param value: Result of the List Queues operation. - :type value: list[~azure.mgmt.servicebus.v2017_04_01.models.SBQueue] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list + :ivar value: Result of the List Queues operation. + :vartype value: list[~azure.mgmt.servicebus.v2017_04_01.models.SBQueue] + :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of queues. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -1786,6 +2102,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of the List Queues operation. + :paramtype value: list[~azure.mgmt.servicebus.v2017_04_01.models.SBQueue] + :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete + list of queues. + :paramtype next_link: str + """ super(SBQueueListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1796,15 +2119,15 @@ class SBSku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. Name of this SKU. Possible values include: "Basic", "Standard", + :ivar name: Required. Name of this SKU. Possible values include: "Basic", "Standard", "Premium". - :type name: str or ~azure.mgmt.servicebus.v2017_04_01.models.SkuName - :param tier: The billing tier of this particular SKU. Possible values include: "Basic", + :vartype name: str or ~azure.mgmt.servicebus.v2017_04_01.models.SkuName + :ivar tier: The billing tier of this particular SKU. Possible values include: "Basic", "Standard", "Premium". - :type tier: str or ~azure.mgmt.servicebus.v2017_04_01.models.SkuTier - :param capacity: The specified messaging units for the tier. For Premium tier, capacity are 1,2 + :vartype tier: str or ~azure.mgmt.servicebus.v2017_04_01.models.SkuTier + :ivar capacity: The specified messaging units for the tier. For Premium tier, capacity are 1,2 and 4. - :type capacity: int + :vartype capacity: int """ _validation = { @@ -1825,6 +2148,17 @@ def __init__( capacity: Optional[int] = None, **kwargs ): + """ + :keyword name: Required. Name of this SKU. Possible values include: "Basic", "Standard", + "Premium". + :paramtype name: str or ~azure.mgmt.servicebus.v2017_04_01.models.SkuName + :keyword tier: The billing tier of this particular SKU. Possible values include: "Basic", + "Standard", "Premium". + :paramtype tier: str or ~azure.mgmt.servicebus.v2017_04_01.models.SkuTier + :keyword capacity: The specified messaging units for the tier. For Premium tier, capacity are + 1,2 and 4. + :paramtype capacity: int + """ super(SBSku, self).__init__(**kwargs) self.name = name self.tier = tier @@ -1852,40 +2186,40 @@ class SBSubscription(Resource): :vartype updated_at: ~datetime.datetime :ivar count_details: Message count details. :vartype count_details: ~azure.mgmt.servicebus.v2017_04_01.models.MessageCountDetails - :param lock_duration: ISO 8061 lock duration timespan for the subscription. The default value - is 1 minute. - :type lock_duration: ~datetime.timedelta - :param requires_session: Value indicating if a subscription supports the concept of sessions. - :type requires_session: bool - :param default_message_time_to_live: ISO 8061 Default message timespan to live value. This is + :ivar lock_duration: ISO 8061 lock duration timespan for the subscription. The default value is + 1 minute. + :vartype lock_duration: ~datetime.timedelta + :ivar requires_session: Value indicating if a subscription supports the concept of sessions. + :vartype requires_session: bool + :ivar default_message_time_to_live: ISO 8061 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_filter_evaluation_exceptions: Value that indicates whether a + :vartype default_message_time_to_live: ~datetime.timedelta + :ivar dead_lettering_on_filter_evaluation_exceptions: Value that indicates whether a subscription has dead letter support on filter evaluation exceptions. - :type dead_lettering_on_filter_evaluation_exceptions: bool - :param dead_lettering_on_message_expiration: Value that indicates whether a subscription has + :vartype dead_lettering_on_filter_evaluation_exceptions: bool + :ivar dead_lettering_on_message_expiration: Value that indicates whether a subscription 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: Number of maximum deliveries. - :type max_delivery_count: int - :param status: Enumerates the possible values for the status of a messaging entity. Possible + :vartype duplicate_detection_history_time_window: ~datetime.timedelta + :ivar max_delivery_count: Number of maximum deliveries. + :vartype max_delivery_count: int + :ivar status: Enumerates the possible values for the status of a messaging entity. Possible values include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", "Deleting", "Renaming", "Unknown". - :type status: str or ~azure.mgmt.servicebus.v2017_04_01.models.EntityStatus - :param enable_batched_operations: Value that indicates whether server-side batched operations + :vartype status: str or ~azure.mgmt.servicebus.v2017_04_01.models.EntityStatus + :ivar enable_batched_operations: Value that indicates whether server-side batched operations are enabled. - :type enable_batched_operations: bool - :param auto_delete_on_idle: ISO 8061 timeSpan idle interval after which the topic is + :vartype enable_batched_operations: bool + :ivar auto_delete_on_idle: ISO 8061 timeSpan idle interval after which the topic is automatically deleted. The minimum duration is 5 minutes. - :type auto_delete_on_idle: ~datetime.timedelta - :param forward_to: Queue/Topic name to forward the messages. - :type forward_to: str - :param forward_dead_lettered_messages_to: Queue/Topic name to forward the Dead Letter message. - :type forward_dead_lettered_messages_to: str + :vartype auto_delete_on_idle: ~datetime.timedelta + :ivar forward_to: Queue/Topic name to forward the messages. + :vartype forward_to: str + :ivar forward_dead_lettered_messages_to: Queue/Topic name to forward the Dead Letter message. + :vartype forward_dead_lettered_messages_to: str """ _validation = { @@ -1939,6 +2273,43 @@ def __init__( forward_dead_lettered_messages_to: Optional[str] = None, **kwargs ): + """ + :keyword lock_duration: ISO 8061 lock duration timespan for the subscription. The default value + is 1 minute. + :paramtype lock_duration: ~datetime.timedelta + :keyword requires_session: Value indicating if a subscription supports the concept of sessions. + :paramtype requires_session: bool + :keyword default_message_time_to_live: ISO 8061 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_filter_evaluation_exceptions: Value that indicates whether a + subscription has dead letter support on filter evaluation exceptions. + :paramtype dead_lettering_on_filter_evaluation_exceptions: bool + :keyword dead_lettering_on_message_expiration: Value that indicates whether a subscription 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: Number of maximum deliveries. + :paramtype max_delivery_count: int + :keyword status: Enumerates the possible values for the status of a messaging entity. Possible + values include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", + "Creating", "Deleting", "Renaming", "Unknown". + :paramtype status: str or ~azure.mgmt.servicebus.v2017_04_01.models.EntityStatus + :keyword enable_batched_operations: Value that indicates whether server-side batched operations + are enabled. + :paramtype enable_batched_operations: bool + :keyword auto_delete_on_idle: ISO 8061 timeSpan idle interval after which the topic is + automatically deleted. The minimum duration is 5 minutes. + :paramtype auto_delete_on_idle: ~datetime.timedelta + :keyword forward_to: Queue/Topic name to forward the messages. + :paramtype forward_to: str + :keyword forward_dead_lettered_messages_to: Queue/Topic name to forward the Dead Letter + message. + :paramtype forward_dead_lettered_messages_to: str + """ super(SBSubscription, self).__init__(**kwargs) self.message_count = None self.created_at = None @@ -1962,11 +2333,11 @@ def __init__( class SBSubscriptionListResult(msrest.serialization.Model): """The response to the List Subscriptions operation. - :param value: Result of the List Subscriptions operation. - :type value: list[~azure.mgmt.servicebus.v2017_04_01.models.SBSubscription] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list + :ivar value: Result of the List Subscriptions operation. + :vartype value: list[~azure.mgmt.servicebus.v2017_04_01.models.SBSubscription] + :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of subscriptions. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -1981,6 +2352,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of the List Subscriptions operation. + :paramtype value: list[~azure.mgmt.servicebus.v2017_04_01.models.SBSubscription] + :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete + list of subscriptions. + :paramtype next_link: str + """ super(SBSubscriptionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -2009,37 +2387,37 @@ class SBTopic(Resource): :vartype subscription_count: int :ivar count_details: Message count details. :vartype count_details: ~azure.mgmt.servicebus.v2017_04_01.models.MessageCountDetails - :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: Maximum size of the topic in megabytes, which is the size of the + :vartype default_message_time_to_live: ~datetime.timedelta + :ivar max_size_in_megabytes: Maximum size of the topic in megabytes, which is the size of the memory allocated for the topic. Default is 1024. - :type max_size_in_megabytes: int - :param requires_duplicate_detection: Value indicating if this topic requires duplicate + :vartype max_size_in_megabytes: int + :ivar requires_duplicate_detection: Value indicating if this topic requires duplicate detection. - :type requires_duplicate_detection: bool - :param duplicate_detection_history_time_window: ISO8601 timespan structure that defines the + :vartype requires_duplicate_detection: bool + :ivar duplicate_detection_history_time_window: ISO8601 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 status: Enumerates the possible values for the status of a messaging entity. Possible + :vartype enable_batched_operations: bool + :ivar status: Enumerates the possible values for the status of a messaging entity. Possible values include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", "Deleting", "Renaming", "Unknown". - :type status: str or ~azure.mgmt.servicebus.v2017_04_01.models.EntityStatus - :param support_ordering: Value that indicates whether the topic supports ordering. - :type support_ordering: bool - :param auto_delete_on_idle: ISO 8601 timespan idle interval after which the topic is + :vartype status: str or ~azure.mgmt.servicebus.v2017_04_01.models.EntityStatus + :ivar support_ordering: Value that indicates whether the topic supports ordering. + :vartype support_ordering: bool + :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: Value that indicates whether the topic to be partitioned across + :vartype auto_delete_on_idle: ~datetime.timedelta + :ivar enable_partitioning: Value that indicates whether the topic to be partitioned across multiple message brokers is enabled. - :type enable_partitioning: bool - :param enable_express: Value that indicates whether Express Entities are enabled. An express + :vartype enable_partitioning: bool + :ivar enable_express: 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 + :vartype enable_express: bool """ _validation = { @@ -2091,6 +2469,39 @@ def __init__( enable_express: Optional[bool] = None, **kwargs ): + """ + :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: Maximum size of the topic in megabytes, which is the size of + the memory allocated for the topic. Default is 1024. + :paramtype max_size_in_megabytes: int + :keyword requires_duplicate_detection: Value indicating if this topic requires duplicate + detection. + :paramtype requires_duplicate_detection: bool + :keyword duplicate_detection_history_time_window: ISO8601 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 status: Enumerates the possible values for the status of a messaging entity. Possible + values include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", + "Creating", "Deleting", "Renaming", "Unknown". + :paramtype status: str or ~azure.mgmt.servicebus.v2017_04_01.models.EntityStatus + :keyword support_ordering: Value that indicates whether the topic supports ordering. + :paramtype support_ordering: bool + :keyword auto_delete_on_idle: ISO 8601 timespan idle interval after which the topic is + automatically deleted. The minimum duration is 5 minutes. + :paramtype auto_delete_on_idle: ~datetime.timedelta + :keyword enable_partitioning: Value that indicates whether the topic to be partitioned across + multiple message brokers is enabled. + :paramtype enable_partitioning: bool + :keyword enable_express: 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 + """ super(SBTopic, self).__init__(**kwargs) self.size_in_bytes = None self.created_at = None @@ -2113,11 +2524,11 @@ def __init__( class SBTopicListResult(msrest.serialization.Model): """The response to the List Topics operation. - :param value: Result of the List Topics operation. - :type value: list[~azure.mgmt.servicebus.v2017_04_01.models.SBTopic] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list + :ivar value: Result of the List Topics operation. + :vartype value: list[~azure.mgmt.servicebus.v2017_04_01.models.SBTopic] + :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of topics. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -2132,6 +2543,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of the List Topics operation. + :paramtype value: list[~azure.mgmt.servicebus.v2017_04_01.models.SBTopic] + :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete + list of topics. + :paramtype next_link: str + """ super(SBTopicListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -2140,14 +2558,14 @@ def __init__( class SqlFilter(msrest.serialization.Model): """Represents a filter which is a composition of an expression and an action that is executed in the pub/sub pipeline. - :param sql_expression: The SQL expression. e.g. MyProperty='ABC'. - :type sql_expression: str - :param compatibility_level: This property is reserved for future use. An integer value showing + :ivar sql_expression: The SQL expression. e.g. MyProperty='ABC'. + :vartype sql_expression: str + :ivar compatibility_level: This property is reserved for future use. An integer value showing the compatibility level, currently hard-coded to 20. - :type compatibility_level: int - :param requires_preprocessing: Value that indicates whether the rule action requires + :vartype compatibility_level: int + :ivar requires_preprocessing: Value that indicates whether the rule action requires preprocessing. - :type requires_preprocessing: bool + :vartype requires_preprocessing: bool """ _validation = { @@ -2168,6 +2586,16 @@ def __init__( requires_preprocessing: Optional[bool] = True, **kwargs ): + """ + :keyword sql_expression: The SQL expression. e.g. MyProperty='ABC'. + :paramtype sql_expression: str + :keyword compatibility_level: This property is reserved for future use. An integer value + showing the compatibility level, currently hard-coded to 20. + :paramtype compatibility_level: int + :keyword requires_preprocessing: Value that indicates whether the rule action requires + preprocessing. + :paramtype requires_preprocessing: bool + """ super(SqlFilter, self).__init__(**kwargs) self.sql_expression = sql_expression self.compatibility_level = compatibility_level @@ -2177,14 +2605,14 @@ def __init__( class SqlRuleAction(Action): """Represents set of actions written in SQL language-based syntax that is performed against a ServiceBus.Messaging.BrokeredMessage. - :param sql_expression: SQL expression. e.g. MyProperty='ABC'. - :type sql_expression: str - :param compatibility_level: This property is reserved for future use. An integer value showing + :ivar sql_expression: SQL expression. e.g. MyProperty='ABC'. + :vartype sql_expression: str + :ivar compatibility_level: This property is reserved for future use. An integer value showing the compatibility level, currently hard-coded to 20. - :type compatibility_level: int - :param requires_preprocessing: Value that indicates whether the rule action requires + :vartype compatibility_level: int + :ivar requires_preprocessing: Value that indicates whether the rule action requires preprocessing. - :type requires_preprocessing: bool + :vartype requires_preprocessing: bool """ _attribute_map = { @@ -2201,6 +2629,16 @@ def __init__( requires_preprocessing: Optional[bool] = True, **kwargs ): + """ + :keyword sql_expression: SQL expression. e.g. MyProperty='ABC'. + :paramtype sql_expression: str + :keyword compatibility_level: This property is reserved for future use. An integer value + showing the compatibility level, currently hard-coded to 20. + :paramtype compatibility_level: int + :keyword requires_preprocessing: Value that indicates whether the rule action requires + preprocessing. + :paramtype requires_preprocessing: bool + """ super(SqlRuleAction, self).__init__(sql_expression=sql_expression, compatibility_level=compatibility_level, requires_preprocessing=requires_preprocessing, **kwargs) @@ -2209,8 +2647,8 @@ class Subnet(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Required. Resource ID of Virtual Network Subnet. - :type id: str + :ivar id: Required. Resource ID of Virtual Network Subnet. + :vartype id: str """ _validation = { @@ -2227,5 +2665,9 @@ def __init__( id: str, **kwargs ): + """ + :keyword id: Required. Resource ID of Virtual Network Subnet. + :paramtype id: str + """ super(Subnet, self).__init__(**kwargs) self.id = id diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/models/_service_bus_management_client_enums.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/models/_service_bus_management_client_enums.py index 0d0adb0e71cd..872ebcd08aed 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/models/_service_bus_management_client_enums.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/models/_service_bus_management_client_enums.py @@ -6,47 +6,32 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AccessRights(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MANAGE = "Manage" SEND = "Send" LISTEN = "Listen" -class DefaultAction(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DefaultAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Default Action for Network Rule Set """ ALLOW = "Allow" DENY = "Deny" -class EncodingCaptureDescription(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class EncodingCaptureDescription(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Enumerates the possible values for the encoding format of capture description. """ AVRO = "Avro" AVRO_DEFLATE = "AvroDeflate" -class EntityStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class EntityStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Entity status. """ @@ -60,25 +45,25 @@ class EntityStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): RENAMING = "Renaming" UNKNOWN = "Unknown" -class FilterType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class FilterType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Rule filter types """ SQL_FILTER = "SqlFilter" CORRELATION_FILTER = "CorrelationFilter" -class KeyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class KeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The access key to regenerate. """ PRIMARY_KEY = "PrimaryKey" SECONDARY_KEY = "SecondaryKey" -class MigrationConfigurationName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class MigrationConfigurationName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): _DEFAULT = "$default" -class NameSpaceType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class NameSpaceType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of namespaces """ @@ -88,13 +73,13 @@ class NameSpaceType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): EVENT_HUB = "EventHub" RELAY = "Relay" -class NetworkRuleIPAction(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class NetworkRuleIPAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The IP Filter Action """ ALLOW = "Allow" -class ProvisioningStateDR(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningStateDR(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Provisioning state of the Alias(Disaster Recovery configuration) - possible values 'Accepted' or 'Succeeded' or 'Failed' """ @@ -103,7 +88,7 @@ class ProvisioningStateDR(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" FAILED = "Failed" -class RoleDisasterRecovery(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RoleDisasterRecovery(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """role of namespace in GEO DR - possible values 'Primary' or 'PrimaryNotReplicating' or 'Secondary' """ @@ -112,7 +97,7 @@ class RoleDisasterRecovery(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PRIMARY_NOT_REPLICATING = "PrimaryNotReplicating" SECONDARY = "Secondary" -class SkuName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Name of this SKU. """ @@ -120,7 +105,7 @@ class SkuName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): STANDARD = "Standard" PREMIUM = "Premium" -class SkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The billing tier of this particular SKU. """ @@ -128,7 +113,7 @@ class SkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): STANDARD = "Standard" PREMIUM = "Premium" -class UnavailableReason(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class UnavailableReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Specifies the reason for the unavailability of the service. """ diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_disaster_recovery_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_disaster_recovery_configs_operations.py index d9faa08e2c17..ed73bb4d6e43 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_disaster_recovery_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_disaster_recovery_configs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,421 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_check_name_availability_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + namespace_name: str, + alias: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + namespace_name: str, + alias: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + namespace_name: str, + alias: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_break_pairing_request( + resource_group_name: str, + namespace_name: str, + alias: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_fail_over_request( + resource_group_name: str, + namespace_name: str, + alias: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_authorization_rules_request( + resource_group_name: str, + namespace_name: str, + alias: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/AuthorizationRules") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + alias: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/AuthorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_keys_request( + resource_group_name: str, + namespace_name: str, + alias: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/AuthorizationRules/{authorizationRuleName}/listKeys") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class DisasterRecoveryConfigsOperations(object): """DisasterRecoveryConfigsOperations operations. @@ -45,14 +444,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def check_name_availability( self, - resource_group_name, # type: str - namespace_name, # type: str - parameters, # type: "_models.CheckNameAvailability" - **kwargs # type: Any - ): - # type: (...) -> "_models.CheckNameAvailabilityResult" + resource_group_name: str, + namespace_name: str, + parameters: "_models.CheckNameAvailability", + **kwargs: Any + ) -> "_models.CheckNameAvailabilityResult": """Check the give namespace name availability. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -71,38 +470,34 @@ def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CheckNameAvailability') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'CheckNameAvailability') + + request = build_check_name_availability_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) @@ -111,15 +506,17 @@ def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability"} # type: ignore + + + @distributed_trace def list( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ArmDisasterRecoveryListResult"] + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> Iterable["_models.ArmDisasterRecoveryListResult"]: """Gets all Alias(Disaster Recovery configurations). :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -127,45 +524,48 @@ def list( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ArmDisasterRecoveryListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.ArmDisasterRecoveryListResult] + :return: An iterator like instance of either ArmDisasterRecoveryListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.ArmDisasterRecoveryListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ArmDisasterRecoveryListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ArmDisasterRecoveryListResult', pipeline_response) + deserialized = self._deserialize("ArmDisasterRecoveryListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -174,30 +574,35 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs"} # type: ignore + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - namespace_name, # type: str - alias, # type: str - parameters, # type: "_models.ArmDisasterRecovery" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ArmDisasterRecovery"] + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: "_models.ArmDisasterRecovery", + **kwargs: Any + ) -> Optional["_models.ArmDisasterRecovery"]: """Creates or updates a new Alias(Disaster Recovery configuration). :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -218,39 +623,35 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ArmDisasterRecovery') - 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) + + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ArmDisasterRecovery') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -261,16 +662,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}'} # type: ignore - def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - alias, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + alias: str, + **kwargs: Any + ) -> None: """Deletes an Alias(Disaster Recovery configuration). :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -289,49 +692,47 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - namespace_name, # type: str - alias, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ArmDisasterRecovery" + resource_group_name: str, + namespace_name: str, + alias: str, + **kwargs: Any + ) -> "_models.ArmDisasterRecovery": """Retrieves Alias(Disaster Recovery configuration) for primary or secondary namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -350,34 +751,31 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) @@ -386,16 +784,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}'} # type: ignore - def break_pairing( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore + + + @distributed_trace + def break_pairing( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - alias, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + alias: str, + **kwargs: Any + ) -> None: """This operation disables the Disaster Recovery and stops replicating changes from primary to secondary namespaces. @@ -415,49 +815,47 @@ def break_pairing( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.break_pairing.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_break_pairing_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.break_pairing.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - break_pairing.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing'} # type: ignore + break_pairing.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing"} # type: ignore - def fail_over( + + @distributed_trace + def fail_over( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - alias, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + alias: str, + **kwargs: Any + ) -> None: """Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -476,49 +874,47 @@ def fail_over( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.fail_over.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_fail_over_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.fail_over.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - fail_over.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover'} # type: ignore + fail_over.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover"} # type: ignore + + @distributed_trace def list_authorization_rules( self, - resource_group_name, # type: str - namespace_name, # type: str - alias, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SBAuthorizationRuleListResult"] + resource_group_name: str, + namespace_name: str, + alias: str, + **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRuleListResult"]: """Gets the authorization rules for a namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -528,46 +924,50 @@ def list_authorization_rules( :param alias: The Disaster Recovery configuration name. :type alias: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRuleListResult] + :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SBAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -576,30 +976,35 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/AuthorizationRules'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/AuthorizationRules"} # type: ignore + @distributed_trace def get_authorization_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - alias, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SBAuthorizationRule" + resource_group_name: str, + namespace_name: str, + alias: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.SBAuthorizationRule": """Gets an authorization rule for a namespace by rule name. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -620,35 +1025,32 @@ def get_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -657,17 +1059,19 @@ def get_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/AuthorizationRules/{authorizationRuleName}'} # type: ignore + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/AuthorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace def list_keys( self, - resource_group_name, # type: str - namespace_name, # type: str - alias, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessKeys" + resource_group_name: str, + namespace_name: str, + alias: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.AccessKeys": """Gets the primary and secondary connection strings for the namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -688,35 +1092,32 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -725,4 +1126,6 @@ def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/AuthorizationRules/{authorizationRuleName}/listKeys'} # type: ignore + + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_event_hubs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_event_hubs_operations.py index 907b14a4edcc..821e157fd9a3 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_event_hubs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_event_hubs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,60 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_namespace_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/eventhubs") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class EventHubsOperations(object): """EventHubsOperations operations. @@ -45,13 +83,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_namespace( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.EventHubListResult"] + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> Iterable["_models.EventHubListResult"]: """Gets all the Event Hubs in a service bus Namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -60,44 +98,46 @@ def list_by_namespace( :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EventHubListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.EventHubListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.EventHubListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_namespace.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_namespace.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('EventHubListResult', pipeline_response) + deserialized = self._deserialize("EventHubListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,17 +146,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_namespace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/eventhubs'} # type: ignore + list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/eventhubs"} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_migration_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_migration_configs_operations.py index a7074101ba36..3ff0156fbe6e 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_migration_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_migration_configs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,25 +6,261 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_and_start_migration_request_initial( + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_complete_migration_request( + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_revert_request( + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class MigrationConfigsOperations(object): """MigrationConfigsOperations operations. @@ -47,13 +284,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MigrationConfigListResult"] + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> Iterable["_models.MigrationConfigListResult"]: """Gets all migrationConfigurations. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -61,45 +298,48 @@ def list( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MigrationConfigListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigListResult] + :return: An iterator like instance of either MigrationConfigListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.MigrationConfigListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('MigrationConfigListResult', pipeline_response) + deserialized = self._deserialize("MigrationConfigListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -108,69 +348,68 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations"} # type: ignore def _create_and_start_migration_initial( self, - resource_group_name, # type: str - namespace_name, # type: str - config_name, # type: Union[str, "_models.MigrationConfigurationName"] - parameters, # type: "_models.MigrationConfigProperties" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.MigrationConfigProperties"] + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + parameters: "_models.MigrationConfigProperties", + **kwargs: Any + ) -> Optional["_models.MigrationConfigProperties"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.MigrationConfigProperties"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_and_start_migration_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'MigrationConfigProperties') - 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) + + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'MigrationConfigProperties') + + request = build_create_and_start_migration_request_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_and_start_migration_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -180,17 +419,19 @@ def _create_and_start_migration_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_and_start_migration_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}'} # type: ignore + _create_and_start_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + + + @distributed_trace def begin_create_and_start_migration( self, - resource_group_name, # type: str - namespace_name, # type: str - config_name, # type: Union[str, "_models.MigrationConfigurationName"] - parameters, # type: "_models.MigrationConfigProperties" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.MigrationConfigProperties"] + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + parameters: "_models.MigrationConfigProperties", + **kwargs: Any + ) -> LROPoller["_models.MigrationConfigProperties"]: """Creates Migration configuration and starts migration of entities from Standard to Premium namespace. @@ -204,14 +445,20 @@ def begin_create_and_start_migration( :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigProperties :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either MigrationConfigProperties or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigProperties] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MigrationConfigProperties or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigProperties] + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.MigrationConfigProperties"] lro_delay = kwargs.pop( @@ -225,28 +472,22 @@ def begin_create_and_start_migration( namespace_name=namespace_name, config_name=config_name, parameters=parameters, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -256,18 +497,18 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_and_start_migration.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def delete( + begin_create_and_start_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - config_name, # type: Union[str, "_models.MigrationConfigurationName"] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + **kwargs: Any + ) -> None: """Deletes a MigrationConfiguration. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -286,49 +527,47 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - namespace_name, # type: str - config_name, # type: Union[str, "_models.MigrationConfigurationName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.MigrationConfigProperties" + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + **kwargs: Any + ) -> "_models.MigrationConfigProperties": """Retrieves Migration Config. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -347,34 +586,31 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) @@ -383,16 +619,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}'} # type: ignore - def complete_migration( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + + + @distributed_trace + def complete_migration( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - config_name, # type: Union[str, "_models.MigrationConfigurationName"] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + **kwargs: Any + ) -> None: """This operation Completes Migration of entities by pointing the connection strings to Premium namespace and any entities created after the operation will be under Premium Namespace. CompleteMigration operation will fail when entity migration is in-progress. @@ -413,49 +651,47 @@ def complete_migration( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.complete_migration.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_complete_migration_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.complete_migration.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - complete_migration.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade'} # type: ignore + complete_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade"} # type: ignore - def revert( + + @distributed_trace + def revert( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - config_name, # type: Union[str, "_models.MigrationConfigurationName"] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + **kwargs: Any + ) -> None: """This operation reverts Migration. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -474,37 +710,35 @@ def revert( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.revert.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_revert_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.revert.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - revert.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert'} # type: ignore + revert.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_namespaces_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_namespaces_operations.py index ecc0fd2f131e..c0de7b55c545 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_namespaces_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_namespaces_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,25 +6,695 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_authorization_rules_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_keys_request( + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_regenerate_keys_request( + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_check_name_availability_request( + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_migrate_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrate") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_create_or_update_network_rule_set_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_network_rule_set_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_network_rule_sets_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class NamespacesOperations(object): """NamespacesOperations operations. @@ -47,13 +718,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_authorization_rules( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SBAuthorizationRuleListResult"] + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRuleListResult"]: """Gets the authorization rules for a namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -61,45 +732,48 @@ def list_authorization_rules( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRuleListResult] + :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SBAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -108,30 +782,35 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules"} # type: ignore + @distributed_trace def create_or_update_authorization_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - authorization_rule_name, # type: str - parameters, # type: "_models.SBAuthorizationRule" - **kwargs # type: Any - ): - # type: (...) -> "_models.SBAuthorizationRule" + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: "_models.SBAuthorizationRule", + **kwargs: Any + ) -> "_models.SBAuthorizationRule": """Creates or updates an authorization rule for a namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -152,39 +831,35 @@ def create_or_update_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBAuthorizationRule') - 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) + + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBAuthorizationRule') + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -193,16 +868,18 @@ def create_or_update_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}'} # type: ignore - def delete_authorization_rule( + create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace + def delete_authorization_rule( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> None: """Deletes a namespace authorization rule. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -221,49 +898,47 @@ def delete_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.delete_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}'} # type: ignore + delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore + + @distributed_trace def get_authorization_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SBAuthorizationRule" + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.SBAuthorizationRule": """Gets an authorization rule for a namespace by rule name. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -282,34 +957,31 @@ def get_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -318,16 +990,18 @@ def get_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}'} # type: ignore + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace def list_keys( self, - resource_group_name, # type: str - namespace_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessKeys" + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.AccessKeys": """Gets the primary and secondary connection strings for the namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -346,34 +1020,31 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -382,17 +1053,19 @@ def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore + + + @distributed_trace def regenerate_keys( self, - resource_group_name, # type: str - namespace_name, # type: str - authorization_rule_name, # type: str - parameters, # type: "_models.RegenerateAccessKeyParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessKeys" + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: "_models.RegenerateAccessKeyParameters", + **kwargs: Any + ) -> "_models.AccessKeys": """Regenerates the primary or secondary connection strings for the namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -413,39 +1086,35 @@ def regenerate_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -454,14 +1123,16 @@ def regenerate_keys( return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys'} # type: ignore + regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + + + @distributed_trace def check_name_availability( self, - parameters, # type: "_models.CheckNameAvailability" - **kwargs # type: Any - ): - # type: (...) -> "_models.CheckNameAvailabilityResult" + parameters: "_models.CheckNameAvailability", + **kwargs: Any + ) -> "_models.CheckNameAvailabilityResult": """Check the give namespace name availability. :param parameters: Parameters to check availability of the given namespace name. @@ -476,36 +1147,32 @@ def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CheckNameAvailability') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'CheckNameAvailability') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) @@ -514,16 +1181,18 @@ def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability'} # type: ignore - def migrate( + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability"} # type: ignore + + + @distributed_trace + def migrate( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - parameters, # type: "_models.SBNamespaceMigrate" - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + parameters: "_models.SBNamespaceMigrate", + **kwargs: Any + ) -> None: """This operation Migrate the given namespace to provided name type. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -542,90 +1211,88 @@ def migrate( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.migrate.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBNamespaceMigrate') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBNamespaceMigrate') + + request = build_migrate_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.migrate.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - migrate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrate'} # type: ignore + migrate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrate"} # type: ignore + + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SBNamespaceListResult"] + **kwargs: Any + ) -> Iterable["_models.SBNamespaceListResult"]: """Gets all the available namespaces within the subscription, irrespective of the resource groups. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBNamespaceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBNamespaceListResult] + :return: An iterator like instance of either SBNamespaceListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBNamespaceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBNamespaceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SBNamespaceListResult', pipeline_response) + deserialized = self._deserialize("SBNamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -634,70 +1301,77 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces"} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SBNamespaceListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.SBNamespaceListResult"]: """Gets the available namespaces within a resource group. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBNamespaceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBNamespaceListResult] + :return: An iterator like instance of either SBNamespaceListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBNamespaceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBNamespaceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SBNamespaceListResult', pipeline_response) + deserialized = self._deserialize("SBNamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -706,67 +1380,66 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces"} # type: ignore def _create_or_update_initial( self, - resource_group_name, # type: str - namespace_name, # type: str - parameters, # type: "_models.SBNamespace" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.SBNamespace"] + resource_group_name: str, + namespace_name: str, + parameters: "_models.SBNamespace", + **kwargs: Any + ) -> Optional["_models.SBNamespace"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.SBNamespace"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBNamespace') - 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) + + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBNamespace') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -779,16 +1452,18 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - namespace_name, # type: str - parameters, # type: "_models.SBNamespace" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.SBNamespace"] + resource_group_name: str, + namespace_name: str, + parameters: "_models.SBNamespace", + **kwargs: Any + ) -> LROPoller["_models.SBNamespace"]: """Creates or updates a service namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. @@ -800,14 +1475,19 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either SBNamespace or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either SBNamespace or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.SBNamespace"] lro_delay = kwargs.pop( @@ -820,27 +1500,22 @@ def begin_create_or_update( resource_group_name=resource_group_name, namespace_name=namespace_name, parameters=parameters, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('SBNamespace', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -850,63 +1525,59 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def _delete_initial( + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + - def begin_delete( + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes an existing namespace. This operation also removes all associated resources under the namespace. @@ -916,14 +1587,17 @@ def begin_delete( :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2017-04-01") # type: str polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( @@ -935,24 +1609,18 @@ def begin_delete( raw_result = self._delete_initial( resource_group_name=resource_group_name, namespace_name=namespace_name, + api_version=api_version, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -962,17 +1630,17 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SBNamespace" + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> "_models.SBNamespace": """Gets a description for the specified namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -989,33 +1657,30 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBNamespace', pipeline_response) @@ -1024,16 +1689,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + + @distributed_trace def update( self, - resource_group_name, # type: str - namespace_name, # type: str - parameters, # type: "_models.SBNamespaceUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.SBNamespace"] + resource_group_name: str, + namespace_name: str, + parameters: "_models.SBNamespaceUpdateParameters", + **kwargs: Any + ) -> Optional["_models.SBNamespace"]: """Updates a service namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. @@ -1053,38 +1720,34 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -1098,16 +1761,18 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + + @distributed_trace def create_or_update_network_rule_set( self, - resource_group_name, # type: str - namespace_name, # type: str - parameters, # type: "_models.NetworkRuleSet" - **kwargs # type: Any - ): - # type: (...) -> "_models.NetworkRuleSet" + resource_group_name: str, + namespace_name: str, + parameters: "_models.NetworkRuleSet", + **kwargs: Any + ) -> "_models.NetworkRuleSet": """Create or update NetworkRuleSet for a Namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -1126,38 +1791,34 @@ def create_or_update_network_rule_set( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_network_rule_set.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'NetworkRuleSet') - 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) + + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'NetworkRuleSet') + + request = build_create_or_update_network_rule_set_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_network_rule_set.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('NetworkRuleSet', pipeline_response) @@ -1166,15 +1827,17 @@ def create_or_update_network_rule_set( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_network_rule_set.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default'} # type: ignore + create_or_update_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore + + + @distributed_trace def get_network_rule_set( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.NetworkRuleSet" + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> "_models.NetworkRuleSet": """Gets NetworkRuleSet for a Namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -1191,33 +1854,30 @@ def get_network_rule_set( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get_network_rule_set.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_network_rule_set_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_network_rule_set.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('NetworkRuleSet', pipeline_response) @@ -1226,15 +1886,17 @@ def get_network_rule_set( return cls(pipeline_response, deserialized, {}) return deserialized - get_network_rule_set.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default'} # type: ignore + get_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore + + + @distributed_trace def list_network_rule_sets( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.NetworkRuleSetListResult"] + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> Iterable["_models.NetworkRuleSetListResult"]: """Gets list of NetworkRuleSet for a Namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -1242,45 +1904,48 @@ def list_network_rule_sets( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NetworkRuleSetListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleSetListResult] + :return: An iterator like instance of either NetworkRuleSetListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkRuleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_network_rule_sets.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_network_rule_sets_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_network_rule_sets.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_network_rule_sets_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('NetworkRuleSetListResult', pipeline_response) + deserialized = self._deserialize("NetworkRuleSetListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1289,17 +1954,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_network_rule_sets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets'} # type: ignore + list_network_rule_sets.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets"} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_operations.py index 67226cdd2f80..12bbe69bea78 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,50 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.ServiceBus/operations") + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,47 +73,49 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationListResult"] + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: """Lists all of the available ServiceBus REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.OperationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -94,17 +124,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.ServiceBus/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.ServiceBus/operations"} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_premium_messaging_regions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_premium_messaging_regions_operations.py index a023c43b81d7..12b6a516875a 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_premium_messaging_regions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_premium_messaging_regions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,56 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/premiumMessagingRegions") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class PremiumMessagingRegionsOperations(object): """PremiumMessagingRegionsOperations operations. @@ -45,51 +79,52 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PremiumMessagingRegionsListResult"] + **kwargs: Any + ) -> Iterable["_models.PremiumMessagingRegionsListResult"]: """Gets the available premium messaging regions for servicebus. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PremiumMessagingRegionsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.PremiumMessagingRegionsListResult] + :return: An iterator like instance of either PremiumMessagingRegionsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.PremiumMessagingRegionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.PremiumMessagingRegionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PremiumMessagingRegionsListResult', pipeline_response) + deserialized = self._deserialize("PremiumMessagingRegionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,17 +133,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/premiumMessagingRegions'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/premiumMessagingRegions"} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_queues_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_queues_operations.py index b26b3e0d860d..ee9b18cf4800 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_queues_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_queues_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,444 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_authorization_rules_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_keys_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_regenerate_keys_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_namespace_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + *, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if skip is not None: + _query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + if top is not None: + _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class QueuesOperations(object): """QueuesOperations operations. @@ -45,14 +467,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_authorization_rules( self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SBAuthorizationRuleListResult"] + resource_group_name: str, + namespace_name: str, + queue_name: str, + **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRuleListResult"]: """Gets all authorization rules for a queue. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -62,46 +484,50 @@ def list_authorization_rules( :param queue_name: The queue name. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRuleListResult] + :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SBAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,31 +536,36 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules"} # type: ignore + @distributed_trace def create_or_update_authorization_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - authorization_rule_name, # type: str - parameters, # type: "_models.SBAuthorizationRule" - **kwargs # type: Any - ): - # type: (...) -> "_models.SBAuthorizationRule" + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: "_models.SBAuthorizationRule", + **kwargs: Any + ) -> "_models.SBAuthorizationRule": """Creates an authorization rule for a queue. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -157,40 +588,36 @@ def create_or_update_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBAuthorizationRule') - 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) + + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBAuthorizationRule') + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -199,17 +626,19 @@ def create_or_update_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}'} # type: ignore - def delete_authorization_rule( + create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace + def delete_authorization_rule( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> None: """Deletes a queue authorization rule. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -230,51 +659,49 @@ def delete_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.delete_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}'} # type: ignore + delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + @distributed_trace def get_authorization_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SBAuthorizationRule" + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.SBAuthorizationRule": """Gets an authorization rule for a queue by rule name. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -295,35 +722,32 @@ def get_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -332,17 +756,19 @@ def get_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}'} # type: ignore + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace def list_keys( self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessKeys" + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.AccessKeys": """Primary and secondary connection strings to the queue. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -363,35 +789,32 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -400,18 +823,20 @@ def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore + + + @distributed_trace def regenerate_keys( self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - authorization_rule_name, # type: str - parameters, # type: "_models.RegenerateAccessKeyParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessKeys" + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: "_models.RegenerateAccessKeyParameters", + **kwargs: Any + ) -> "_models.AccessKeys": """Regenerates the primary or secondary connection strings to the queue. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -434,40 +859,36 @@ def regenerate_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -476,17 +897,19 @@ def regenerate_keys( return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys'} # type: ignore + regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + + + @distributed_trace def list_by_namespace( self, - resource_group_name, # type: str - namespace_name, # type: str - skip=None, # type: Optional[int] - top=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SBQueueListResult"] + resource_group_name: str, + namespace_name: str, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.SBQueueListResult"]: """Gets the queues within a namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -495,54 +918,57 @@ def list_by_namespace( :type namespace_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. + parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip: int :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SBQueueListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBQueueListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBQueueListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBQueueListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_namespace.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', maximum=1000, minimum=0) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=self.list_by_namespace.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SBQueueListResult', pipeline_response) + deserialized = self._deserialize("SBQueueListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -551,30 +977,35 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_namespace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues'} # type: ignore + list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues"} # type: ignore + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - parameters, # type: "_models.SBQueue" - **kwargs # type: Any - ): - # type: (...) -> "_models.SBQueue" + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: "_models.SBQueue", + **kwargs: Any + ) -> "_models.SBQueue": """Creates or updates a Service Bus queue. This operation is idempotent. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -595,39 +1026,35 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBQueue') - 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) + + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBQueue') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBQueue', pipeline_response) @@ -636,16 +1063,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}'} # type: ignore - def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + queue_name: str, + **kwargs: Any + ) -> None: """Deletes a queue from the specified namespace in a resource group. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -664,49 +1093,47 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SBQueue" + resource_group_name: str, + namespace_name: str, + queue_name: str, + **kwargs: Any + ) -> "_models.SBQueue": """Returns a description for the specified queue. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -725,34 +1152,31 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBQueue', pipeline_response) @@ -761,4 +1185,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_regions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_regions_operations.py index d51da019ed21..2b0e2866740b 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_regions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_regions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,58 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_sku_request( + subscription_id: str, + sku: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/sku/{sku}/regions") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "sku": _SERIALIZER.url("sku", sku, 'str', max_length=50, min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class RegionsOperations(object): """RegionsOperations operations. @@ -45,55 +81,57 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_sku( self, - sku, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PremiumMessagingRegionsListResult"] + sku: str, + **kwargs: Any + ) -> Iterable["_models.PremiumMessagingRegionsListResult"]: """Gets the available Regions for a given sku. :param sku: The sku type. :type sku: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PremiumMessagingRegionsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.PremiumMessagingRegionsListResult] + :return: An iterator like instance of either PremiumMessagingRegionsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.PremiumMessagingRegionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.PremiumMessagingRegionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_sku.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'sku': self._serialize.url("sku", sku, 'str', max_length=50, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_sku_request( + subscription_id=self._config.subscription_id, + sku=sku, + api_version=api_version, + template_url=self.list_by_sku.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_sku_request( + subscription_id=self._config.subscription_id, + sku=sku, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PremiumMessagingRegionsListResult', pipeline_response) + deserialized = self._deserialize("PremiumMessagingRegionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -102,17 +140,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_sku.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/sku/{sku}/regions'} # type: ignore + list_by_sku.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/sku/{sku}/regions"} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_rules_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_rules_operations.py index 6ac47885d166..d799bc10b53e 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_rules_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_rules_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,206 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_subscriptions_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + subscription_id: str, + *, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if skip is not None: + _query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + if top is not None: + _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class RulesOperations(object): """RulesOperations operations. @@ -45,17 +229,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_subscriptions( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - subscription_name, # type: str - skip=None, # type: Optional[int] - top=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RuleListResult"] + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.RuleListResult"]: """List all the rules within given topic-subscription. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -68,56 +252,60 @@ def list_by_subscriptions( :type subscription_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. + parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip: int :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RuleListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.RuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscriptions.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', maximum=1000, minimum=0) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscriptions_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=self.list_by_subscriptions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscriptions_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RuleListResult', pipeline_response) + deserialized = self._deserialize("RuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -126,32 +314,37 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_subscriptions.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules'} # type: ignore + list_by_subscriptions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules"} # type: ignore + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - subscription_name, # type: str - rule_name, # type: str - parameters, # type: "_models.Rule" - **kwargs # type: Any - ): - # type: (...) -> "_models.Rule" + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: "_models.Rule", + **kwargs: Any + ) -> "_models.Rule": """Creates a new rule and updates an existing rule. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -176,41 +369,37 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Rule') - 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) + + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Rule') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Rule', pipeline_response) @@ -219,18 +408,20 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}'} # type: ignore - def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - subscription_name, # type: str - rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + **kwargs: Any + ) -> None: """Deletes an existing rule. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -253,53 +444,51 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - subscription_name, # type: str - rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Rule" + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + **kwargs: Any + ) -> "_models.Rule": """Retrieves the description for the specified rule. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -322,36 +511,33 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Rule', pipeline_response) @@ -360,4 +546,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_subscriptions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_subscriptions_operations.py index b936d1cb8a0c..514318f6b77e 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_subscriptions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_subscriptions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,198 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_topic_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_id: str, + *, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if skip is not None: + _query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + if top is not None: + _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class SubscriptionsOperations(object): """SubscriptionsOperations operations. @@ -45,16 +221,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_topic( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - skip=None, # type: Optional[int] - top=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SBSubscriptionListResult"] + resource_group_name: str, + namespace_name: str, + topic_name: str, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.SBSubscriptionListResult"]: """List all the subscriptions under a specified topic. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -65,55 +241,60 @@ def list_by_topic( :type topic_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. + parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip: int :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBSubscriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBSubscriptionListResult] + :return: An iterator like instance of either SBSubscriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBSubscriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBSubscriptionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_topic.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', maximum=1000, minimum=0) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_topic_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=self.list_by_topic.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_topic_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SBSubscriptionListResult', pipeline_response) + deserialized = self._deserialize("SBSubscriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -122,31 +303,36 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_topic.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions'} # type: ignore + list_by_topic.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions"} # type: ignore + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - subscription_name, # type: str - parameters, # type: "_models.SBSubscription" - **kwargs # type: Any - ): - # type: (...) -> "_models.SBSubscription" + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: "_models.SBSubscription", + **kwargs: Any + ) -> "_models.SBSubscription": """Creates a topic subscription. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -169,40 +355,36 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBSubscription') - 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) + + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBSubscription') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBSubscription', pipeline_response) @@ -211,17 +393,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}'} # type: ignore - def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - subscription_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + **kwargs: Any + ) -> None: """Deletes a subscription from the specified topic. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -242,51 +426,49 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - subscription_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SBSubscription" + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + **kwargs: Any + ) -> "_models.SBSubscription": """Returns a subscription description for the specified topic. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -307,35 +489,32 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBSubscription', pipeline_response) @@ -344,4 +523,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_topics_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_topics_operations.py index 24d62f126806..999db899a3d9 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_topics_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_topics_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,444 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_authorization_rules_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_delete_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_keys_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_regenerate_keys_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_namespace_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + *, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if skip is not None: + _query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + if top is not None: + _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class TopicsOperations(object): """TopicsOperations operations. @@ -45,14 +467,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_authorization_rules( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SBAuthorizationRuleListResult"] + resource_group_name: str, + namespace_name: str, + topic_name: str, + **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRuleListResult"]: """Gets authorization rules for a topic. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -62,46 +484,50 @@ def list_authorization_rules( :param topic_name: The topic name. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRuleListResult] + :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SBAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,31 +536,36 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules"} # type: ignore + @distributed_trace def create_or_update_authorization_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - authorization_rule_name, # type: str - parameters, # type: "_models.SBAuthorizationRule" - **kwargs # type: Any - ): - # type: (...) -> "_models.SBAuthorizationRule" + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: "_models.SBAuthorizationRule", + **kwargs: Any + ) -> "_models.SBAuthorizationRule": """Creates an authorization rule for the specified topic. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -157,40 +588,36 @@ def create_or_update_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBAuthorizationRule') - 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) + + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBAuthorizationRule') + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -199,17 +626,19 @@ def create_or_update_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}'} # type: ignore + create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace def get_authorization_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SBAuthorizationRule" + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.SBAuthorizationRule": """Returns the specified authorization rule. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -230,35 +659,32 @@ def get_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -267,17 +693,19 @@ def get_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}'} # type: ignore - def delete_authorization_rule( + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace + def delete_authorization_rule( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> None: """Deletes a topic authorization rule. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -298,51 +726,49 @@ def delete_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.delete_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}'} # type: ignore + delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + @distributed_trace def list_keys( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessKeys" + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.AccessKeys": """Gets the primary and secondary connection strings for the topic. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -363,35 +789,32 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -400,18 +823,20 @@ def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore + + + @distributed_trace def regenerate_keys( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - authorization_rule_name, # type: str - parameters, # type: "_models.RegenerateAccessKeyParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessKeys" + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: "_models.RegenerateAccessKeyParameters", + **kwargs: Any + ) -> "_models.AccessKeys": """Regenerates primary or secondary connection strings for the topic. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -434,40 +859,36 @@ def regenerate_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -476,17 +897,19 @@ def regenerate_keys( return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys'} # type: ignore + regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + + + @distributed_trace def list_by_namespace( self, - resource_group_name, # type: str - namespace_name, # type: str - skip=None, # type: Optional[int] - top=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SBTopicListResult"] + resource_group_name: str, + namespace_name: str, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.SBTopicListResult"]: """Gets all the topics in a namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -495,54 +918,57 @@ def list_by_namespace( :type namespace_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. + parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip: int :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SBTopicListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBTopicListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBTopicListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBTopicListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_namespace.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', maximum=1000, minimum=0) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=self.list_by_namespace.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SBTopicListResult', pipeline_response) + deserialized = self._deserialize("SBTopicListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -551,30 +977,35 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_namespace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics'} # type: ignore + list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics"} # type: ignore + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - parameters, # type: "_models.SBTopic" - **kwargs # type: Any - ): - # type: (...) -> "_models.SBTopic" + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: "_models.SBTopic", + **kwargs: Any + ) -> "_models.SBTopic": """Creates a topic in the specified namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -595,39 +1026,35 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBTopic') - 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) + + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBTopic') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBTopic', pipeline_response) @@ -636,16 +1063,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}'} # type: ignore - def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + topic_name: str, + **kwargs: Any + ) -> None: """Deletes a topic from the specified namespace and resource group. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -664,49 +1093,47 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SBTopic" + resource_group_name: str, + namespace_name: str, + topic_name: str, + **kwargs: Any + ) -> "_models.SBTopic": """Returns a description for the specified topic. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -725,34 +1152,31 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2017-04-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBTopic', pipeline_response) @@ -761,4 +1185,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/__init__.py index e6ef471ff03a..aa0384448e69 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ServiceBusManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_configuration.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_configuration.py index eea59f0d6c88..3c8663a0c0b6 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_configuration.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_configuration.py @@ -6,22 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -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 @@ -29,26 +27,31 @@ class ServiceBusManagementClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2018-01-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2018-01-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-servicebus/{}'.format(VERSION)) self._configure(**kwargs) @@ -68,4 +71,4 @@ def _configure( 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) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_metadata.json b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_metadata.json index 0a3a5cced250..6a6601651a9e 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_metadata.json +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_metadata.json @@ -5,13 +5,13 @@ "name": "ServiceBusManagementClient", "filename": "_service_bus_management_client", "description": "Azure Service Bus client for managing Namespace, IPFilter Rules, VirtualNetworkRules and Zone Redundant.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "namespaces": "NamespacesOperations", diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_service_bus_management_client.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_service_bus_management_client.py index cdf7ad71819f..88d6082791a6 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_service_bus_management_client.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_service_bus_management_client.py @@ -6,46 +6,37 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient -from ._configuration import ServiceBusManagementClientConfiguration -from .operations import NamespacesOperations -from .operations import PrivateEndpointConnectionsOperations -from .operations import PrivateLinkResourcesOperations -from .operations import DisasterRecoveryConfigsOperations -from .operations import QueuesOperations -from .operations import TopicsOperations -from .operations import EventHubsOperations -from .operations import MigrationConfigsOperations -from .operations import PremiumMessagingRegionsOperations -from .operations import RegionsOperations -from .operations import SubscriptionsOperations -from .operations import RulesOperations -from .operations import Operations from . import models +from ._configuration import ServiceBusManagementClientConfiguration +from .operations import DisasterRecoveryConfigsOperations, EventHubsOperations, MigrationConfigsOperations, NamespacesOperations, Operations, PremiumMessagingRegionsOperations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueuesOperations, RegionsOperations, RulesOperations, SubscriptionsOperations, TopicsOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class ServiceBusManagementClient(object): - """Azure Service Bus client for managing Namespace, IPFilter Rules, VirtualNetworkRules and Zone Redundant. +class ServiceBusManagementClient: # pylint: disable=too-many-instance-attributes + """Azure Service Bus client for managing Namespace, IPFilter Rules, VirtualNetworkRules and Zone + Redundant. :ivar namespaces: NamespacesOperations operations :vartype namespaces: azure.mgmt.servicebus.v2018_01_01_preview.operations.NamespacesOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: azure.mgmt.servicebus.v2018_01_01_preview.operations.PrivateEndpointConnectionsOperations + :vartype private_endpoint_connections: + azure.mgmt.servicebus.v2018_01_01_preview.operations.PrivateEndpointConnectionsOperations :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: azure.mgmt.servicebus.v2018_01_01_preview.operations.PrivateLinkResourcesOperations + :vartype private_link_resources: + azure.mgmt.servicebus.v2018_01_01_preview.operations.PrivateLinkResourcesOperations :ivar disaster_recovery_configs: DisasterRecoveryConfigsOperations operations - :vartype disaster_recovery_configs: azure.mgmt.servicebus.v2018_01_01_preview.operations.DisasterRecoveryConfigsOperations + :vartype disaster_recovery_configs: + azure.mgmt.servicebus.v2018_01_01_preview.operations.DisasterRecoveryConfigsOperations :ivar queues: QueuesOperations operations :vartype queues: azure.mgmt.servicebus.v2018_01_01_preview.operations.QueuesOperations :ivar topics: TopicsOperations operations @@ -53,87 +44,88 @@ class ServiceBusManagementClient(object): :ivar event_hubs: EventHubsOperations operations :vartype event_hubs: azure.mgmt.servicebus.v2018_01_01_preview.operations.EventHubsOperations :ivar migration_configs: MigrationConfigsOperations operations - :vartype migration_configs: azure.mgmt.servicebus.v2018_01_01_preview.operations.MigrationConfigsOperations + :vartype migration_configs: + azure.mgmt.servicebus.v2018_01_01_preview.operations.MigrationConfigsOperations :ivar premium_messaging_regions: PremiumMessagingRegionsOperations operations - :vartype premium_messaging_regions: azure.mgmt.servicebus.v2018_01_01_preview.operations.PremiumMessagingRegionsOperations + :vartype premium_messaging_regions: + azure.mgmt.servicebus.v2018_01_01_preview.operations.PremiumMessagingRegionsOperations :ivar regions: RegionsOperations operations :vartype regions: azure.mgmt.servicebus.v2018_01_01_preview.operations.RegionsOperations :ivar subscriptions: SubscriptionsOperations operations - :vartype subscriptions: azure.mgmt.servicebus.v2018_01_01_preview.operations.SubscriptionsOperations + :vartype subscriptions: + azure.mgmt.servicebus.v2018_01_01_preview.operations.SubscriptionsOperations :ivar rules: RulesOperations operations :vartype rules: azure.mgmt.servicebus.v2018_01_01_preview.operations.RulesOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.servicebus.v2018_01_01_preview.operations.Operations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2018-01-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ServiceBusManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ServiceBusManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - - self.namespaces = NamespacesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.disaster_recovery_configs = DisasterRecoveryConfigsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.queues = QueuesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.topics = TopicsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.event_hubs = EventHubsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.migration_configs = MigrationConfigsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.premium_messaging_regions = PremiumMessagingRegionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.regions = RegionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.rules = RulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + self._serialize.client_side_validation = False + self.namespaces = NamespacesOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.disaster_recovery_configs = DisasterRecoveryConfigsOperations(self._client, self._config, self._serialize, self._deserialize) + self.queues = QueuesOperations(self._client, self._config, self._serialize, self._deserialize) + self.topics = TopicsOperations(self._client, self._config, self._serialize, self._deserialize) + self.event_hubs = EventHubsOperations(self._client, self._config, self._serialize, self._deserialize) + self.migration_configs = MigrationConfigsOperations(self._client, self._config, self._serialize, self._deserialize) + self.premium_messaging_regions = PremiumMessagingRegionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.regions = RegionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.rules = RulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(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. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_vendor.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# 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 azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_version.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_version.py index e7ffc58c0429..e5754a47ce68 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_version.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "7.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/__init__.py index 9016cbc21795..1b5398b4946f 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/__init__.py @@ -8,3 +8,8 @@ from ._service_bus_management_client import ServiceBusManagementClient __all__ = ['ServiceBusManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/_configuration.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/_configuration.py index df598af613b6..6808f4a0adc0 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/_configuration.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -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 @@ -27,8 +27,12 @@ class ServiceBusManagementClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2018-01-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -37,15 +41,17 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2018-01-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-servicebus/{}'.format(VERSION)) self._configure(**kwargs) @@ -64,4 +70,4 @@ def _configure( 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) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/_service_bus_management_client.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/_service_bus_management_client.py index b64408c38517..7ac55fcf67f9 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/_service_bus_management_client.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/_service_bus_management_client.py @@ -6,130 +6,128 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient -from ._configuration import ServiceBusManagementClientConfiguration -from .operations import NamespacesOperations -from .operations import PrivateEndpointConnectionsOperations -from .operations import PrivateLinkResourcesOperations -from .operations import DisasterRecoveryConfigsOperations -from .operations import QueuesOperations -from .operations import TopicsOperations -from .operations import EventHubsOperations -from .operations import MigrationConfigsOperations -from .operations import PremiumMessagingRegionsOperations -from .operations import RegionsOperations -from .operations import SubscriptionsOperations -from .operations import RulesOperations -from .operations import Operations from .. import models +from ._configuration import ServiceBusManagementClientConfiguration +from .operations import DisasterRecoveryConfigsOperations, EventHubsOperations, MigrationConfigsOperations, NamespacesOperations, Operations, PremiumMessagingRegionsOperations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueuesOperations, RegionsOperations, RulesOperations, SubscriptionsOperations, TopicsOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class ServiceBusManagementClient(object): - """Azure Service Bus client for managing Namespace, IPFilter Rules, VirtualNetworkRules and Zone Redundant. +class ServiceBusManagementClient: # pylint: disable=too-many-instance-attributes + """Azure Service Bus client for managing Namespace, IPFilter Rules, VirtualNetworkRules and Zone + Redundant. :ivar namespaces: NamespacesOperations operations - :vartype namespaces: azure.mgmt.servicebus.v2018_01_01_preview.aio.operations.NamespacesOperations + :vartype namespaces: + azure.mgmt.servicebus.v2018_01_01_preview.aio.operations.NamespacesOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: azure.mgmt.servicebus.v2018_01_01_preview.aio.operations.PrivateEndpointConnectionsOperations + :vartype private_endpoint_connections: + azure.mgmt.servicebus.v2018_01_01_preview.aio.operations.PrivateEndpointConnectionsOperations :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: azure.mgmt.servicebus.v2018_01_01_preview.aio.operations.PrivateLinkResourcesOperations + :vartype private_link_resources: + azure.mgmt.servicebus.v2018_01_01_preview.aio.operations.PrivateLinkResourcesOperations :ivar disaster_recovery_configs: DisasterRecoveryConfigsOperations operations - :vartype disaster_recovery_configs: azure.mgmt.servicebus.v2018_01_01_preview.aio.operations.DisasterRecoveryConfigsOperations + :vartype disaster_recovery_configs: + azure.mgmt.servicebus.v2018_01_01_preview.aio.operations.DisasterRecoveryConfigsOperations :ivar queues: QueuesOperations operations :vartype queues: azure.mgmt.servicebus.v2018_01_01_preview.aio.operations.QueuesOperations :ivar topics: TopicsOperations operations :vartype topics: azure.mgmt.servicebus.v2018_01_01_preview.aio.operations.TopicsOperations :ivar event_hubs: EventHubsOperations operations - :vartype event_hubs: azure.mgmt.servicebus.v2018_01_01_preview.aio.operations.EventHubsOperations + :vartype event_hubs: + azure.mgmt.servicebus.v2018_01_01_preview.aio.operations.EventHubsOperations :ivar migration_configs: MigrationConfigsOperations operations - :vartype migration_configs: azure.mgmt.servicebus.v2018_01_01_preview.aio.operations.MigrationConfigsOperations + :vartype migration_configs: + azure.mgmt.servicebus.v2018_01_01_preview.aio.operations.MigrationConfigsOperations :ivar premium_messaging_regions: PremiumMessagingRegionsOperations operations - :vartype premium_messaging_regions: azure.mgmt.servicebus.v2018_01_01_preview.aio.operations.PremiumMessagingRegionsOperations + :vartype premium_messaging_regions: + azure.mgmt.servicebus.v2018_01_01_preview.aio.operations.PremiumMessagingRegionsOperations :ivar regions: RegionsOperations operations :vartype regions: azure.mgmt.servicebus.v2018_01_01_preview.aio.operations.RegionsOperations :ivar subscriptions: SubscriptionsOperations operations - :vartype subscriptions: azure.mgmt.servicebus.v2018_01_01_preview.aio.operations.SubscriptionsOperations + :vartype subscriptions: + azure.mgmt.servicebus.v2018_01_01_preview.aio.operations.SubscriptionsOperations :ivar rules: RulesOperations operations :vartype rules: azure.mgmt.servicebus.v2018_01_01_preview.aio.operations.RulesOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.servicebus.v2018_01_01_preview.aio.operations.Operations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2018-01-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = ServiceBusManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ServiceBusManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.namespaces = NamespacesOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.disaster_recovery_configs = DisasterRecoveryConfigsOperations(self._client, self._config, self._serialize, self._deserialize) + self.queues = QueuesOperations(self._client, self._config, self._serialize, self._deserialize) + self.topics = TopicsOperations(self._client, self._config, self._serialize, self._deserialize) + self.event_hubs = EventHubsOperations(self._client, self._config, self._serialize, self._deserialize) + self.migration_configs = MigrationConfigsOperations(self._client, self._config, self._serialize, self._deserialize) + self.premium_messaging_regions = PremiumMessagingRegionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.regions = RegionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.rules = RulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.namespaces = NamespacesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.disaster_recovery_configs = DisasterRecoveryConfigsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.queues = QueuesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.topics = TopicsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.event_hubs = EventHubsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.migration_configs = MigrationConfigsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.premium_messaging_regions = PremiumMessagingRegionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.regions = RegionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.rules = RulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_disaster_recovery_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_disaster_recovery_configs_operations.py index 84c77d671505..f844bbd6ce1c 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_disaster_recovery_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_disaster_recovery_configs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._disaster_recovery_configs_operations import build_break_pairing_request, build_check_name_availability_request, build_create_or_update_request, build_delete_request, build_fail_over_request, build_get_authorization_rule_request, build_get_request, build_list_authorization_rules_request, build_list_keys_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def check_name_availability( self, resource_group_name: str, @@ -66,38 +71,34 @@ async def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CheckNameAvailability') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'CheckNameAvailability') + + request = build_check_name_availability_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) @@ -106,8 +107,11 @@ async def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability"} # type: ignore + + + @distributed_trace def list( self, resource_group_name: str, @@ -121,45 +125,48 @@ def list( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ArmDisasterRecoveryListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.ArmDisasterRecoveryListResult] + :return: An iterator like instance of either ArmDisasterRecoveryListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.ArmDisasterRecoveryListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ArmDisasterRecoveryListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ArmDisasterRecoveryListResult', pipeline_response) + deserialized = self._deserialize("ArmDisasterRecoveryListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -168,21 +175,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs"} # type: ignore + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -211,39 +224,35 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ArmDisasterRecovery') - 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) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ArmDisasterRecovery') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -254,9 +263,12 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}'} # type: ignore - async def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -281,41 +293,40 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -341,34 +352,31 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) @@ -377,9 +385,12 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}'} # type: ignore - async def break_pairing( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore + + + @distributed_trace_async + async def break_pairing( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -405,42 +416,41 @@ async def break_pairing( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.break_pairing.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_break_pairing_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.break_pairing.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - break_pairing.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing'} # type: ignore + break_pairing.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing"} # type: ignore - async def fail_over( + + @distributed_trace_async + async def fail_over( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -457,6 +467,7 @@ async def fail_over( :param alias: The Disaster Recovery configuration name. :type alias: str :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Default value is None. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.FailoverProperties :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) @@ -468,49 +479,47 @@ async def fail_over( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.fail_over.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if parameters is not None: - body_content = self._serialize.body(parameters, 'FailoverProperties') + _json = self._serialize.body(parameters, 'FailoverProperties') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + _json = None + + request = build_fail_over_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.fail_over.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - fail_over.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover'} # type: ignore + fail_over.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover"} # type: ignore + + @distributed_trace def list_authorization_rules( self, resource_group_name: str, @@ -527,46 +536,50 @@ def list_authorization_rules( :param alias: The Disaster Recovery configuration name. :type alias: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRuleListResult] + :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SBAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -575,21 +588,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules"} # type: ignore + @distributed_trace_async async def get_authorization_rule( self, resource_group_name: str, @@ -618,35 +637,32 @@ async def get_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -655,8 +671,11 @@ async def get_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}'} # type: ignore + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace_async async def list_keys( self, resource_group_name: str, @@ -685,35 +704,32 @@ async def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -722,4 +738,6 @@ async def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys'} # type: ignore + + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_event_hubs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_event_hubs_operations.py index da37d7f759ee..671cd7e8d1bc 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_event_hubs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_event_hubs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,19 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._event_hubs_operations import build_list_by_namespace_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_namespace( self, resource_group_name: str, @@ -55,44 +59,46 @@ def list_by_namespace( :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EventHubListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.EventHubListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.EventHubListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_namespace.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_namespace.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('EventHubListResult', pipeline_response) + deserialized = self._deserialize("EventHubListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -101,17 +107,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_namespace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/eventhubs'} # type: ignore + list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/eventhubs"} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_migration_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_migration_configs_operations.py index 0844d0922df0..1b600b4657af 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_migration_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_migration_configs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,19 +6,22 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._migration_configs_operations import build_complete_migration_request, build_create_and_start_migration_request_initial, build_delete_request, build_get_request, build_list_request, build_revert_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +47,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name: str, @@ -56,45 +61,48 @@ def list( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MigrationConfigListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigListResult] + :return: An iterator like instance of either MigrationConfigListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.MigrationConfigListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('MigrationConfigListResult', pipeline_response) + deserialized = self._deserialize("MigrationConfigListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,20 +111,25 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations"} # type: ignore async def _create_and_start_migration_initial( self, @@ -131,40 +144,35 @@ async def _create_and_start_migration_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_and_start_migration_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'MigrationConfigProperties') - 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) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'MigrationConfigProperties') + + request = build_create_and_start_migration_request_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_and_start_migration_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -174,8 +182,11 @@ async def _create_and_start_migration_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_and_start_migration_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}'} # type: ignore + _create_and_start_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + + + @distributed_trace_async async def begin_create_and_start_migration( self, resource_group_name: str, @@ -192,19 +203,26 @@ async def begin_create_and_start_migration( :param namespace_name: The namespace name. :type namespace_name: str :param config_name: The configuration name. Should always be "$default". - :type config_name: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigurationName + :type config_name: str or + ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigurationName :param parameters: Parameters required to create Migration Configuration. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigProperties :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either MigrationConfigProperties or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigProperties] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MigrationConfigProperties or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigProperties] + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.MigrationConfigProperties"] lro_delay = kwargs.pop( @@ -218,28 +236,22 @@ async def begin_create_and_start_migration( namespace_name=namespace_name, config_name=config_name, parameters=parameters, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -249,11 +261,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_and_start_migration.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_and_start_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore - async def delete( + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -267,7 +280,8 @@ async def delete( :param namespace_name: The namespace name. :type namespace_name: str :param config_name: The configuration name. Should always be "$default". - :type config_name: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigurationName + :type config_name: str or + ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigurationName :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -278,41 +292,40 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -327,7 +340,8 @@ async def get( :param namespace_name: The namespace name. :type namespace_name: str :param config_name: The configuration name. Should always be "$default". - :type config_name: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigurationName + :type config_name: str or + ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigurationName :keyword callable cls: A custom type or function that will be passed the direct response :return: MigrationConfigProperties, or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigProperties @@ -338,34 +352,31 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) @@ -374,9 +385,12 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}'} # type: ignore - async def complete_migration( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + + + @distributed_trace_async + async def complete_migration( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -392,7 +406,8 @@ async def complete_migration( :param namespace_name: The namespace name. :type namespace_name: str :param config_name: The configuration name. Should always be "$default". - :type config_name: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigurationName + :type config_name: str or + ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigurationName :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -403,42 +418,41 @@ async def complete_migration( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.complete_migration.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_complete_migration_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.complete_migration.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - complete_migration.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade'} # type: ignore + complete_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade"} # type: ignore - async def revert( + + @distributed_trace_async + async def revert( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -452,7 +466,8 @@ async def revert( :param namespace_name: The namespace name. :type namespace_name: str :param config_name: The configuration name. Should always be "$default". - :type config_name: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigurationName + :type config_name: str or + ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigurationName :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -463,37 +478,35 @@ async def revert( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.revert.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_revert_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.revert.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - revert.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert'} # type: ignore + revert.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_namespaces_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_namespaces_operations.py index 7b474ace9b7a..2255ef35e971 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_namespaces_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_namespaces_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,26 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._namespaces_operations import build_check_name_availability_request, build_create_or_update_authorization_rule_request, build_create_or_update_ip_filter_rule_request, build_create_or_update_network_rule_set_request, build_create_or_update_request_initial, build_create_or_update_virtual_network_rule_request, build_delete_authorization_rule_request, build_delete_ip_filter_rule_request, build_delete_request_initial, build_delete_virtual_network_rule_request, build_get_authorization_rule_request, build_get_ip_filter_rule_request, build_get_network_rule_set_request, build_get_request, build_get_virtual_network_rule_request, build_list_authorization_rules_request, build_list_by_resource_group_request, build_list_ip_filter_rules_request, build_list_keys_request, build_list_network_rule_sets_request, build_list_request, build_list_virtual_network_rules_request, build_migrate_request, build_regenerate_keys_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class NamespacesOperations: +class NamespacesOperations: # pylint: disable=too-many-public-methods """NamespacesOperations async operations. You should not instantiate this class directly. Instead, you should create a Client instance that @@ -43,6 +47,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_ip_filter_rules( self, resource_group_name: str, @@ -56,45 +61,48 @@ def list_ip_filter_rules( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IpFilterRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.IpFilterRuleListResult] + :return: An iterator like instance of either IpFilterRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.IpFilterRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.IpFilterRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_ip_filter_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_ip_filter_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_ip_filter_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_ip_filter_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IpFilterRuleListResult', pipeline_response) + deserialized = self._deserialize("IpFilterRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,21 +111,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_ip_filter_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules'} # type: ignore + list_ip_filter_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules"} # type: ignore + @distributed_trace_async async def create_or_update_ip_filter_rule( self, resource_group_name: str, @@ -146,39 +160,35 @@ async def create_or_update_ip_filter_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_ip_filter_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'ipFilterRuleName': self._serialize.url("ip_filter_rule_name", ip_filter_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'IpFilterRule') - 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) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'IpFilterRule') + + request = build_create_or_update_ip_filter_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + ip_filter_rule_name=ip_filter_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_ip_filter_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IpFilterRule', pipeline_response) @@ -187,9 +197,12 @@ async def create_or_update_ip_filter_rule( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_ip_filter_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules/{ipFilterRuleName}'} # type: ignore - async def delete_ip_filter_rule( + create_or_update_ip_filter_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules/{ipFilterRuleName}"} # type: ignore + + + @distributed_trace_async + async def delete_ip_filter_rule( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -214,41 +227,40 @@ async def delete_ip_filter_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_ip_filter_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'ipFilterRuleName': self._serialize.url("ip_filter_rule_name", ip_filter_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_ip_filter_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + ip_filter_rule_name=ip_filter_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_ip_filter_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete_ip_filter_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules/{ipFilterRuleName}'} # type: ignore + delete_ip_filter_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules/{ipFilterRuleName}"} # type: ignore + + @distributed_trace_async async def get_ip_filter_rule( self, resource_group_name: str, @@ -274,34 +286,31 @@ async def get_ip_filter_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_ip_filter_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'ipFilterRuleName': self._serialize.url("ip_filter_rule_name", ip_filter_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_ip_filter_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + ip_filter_rule_name=ip_filter_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_ip_filter_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IpFilterRule', pipeline_response) @@ -310,8 +319,11 @@ async def get_ip_filter_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_ip_filter_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules/{ipFilterRuleName}'} # type: ignore + get_ip_filter_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules/{ipFilterRuleName}"} # type: ignore + + + @distributed_trace def list( self, **kwargs: Any @@ -319,43 +331,44 @@ def list( """Gets all the available namespaces within the subscription, irrespective of the resource groups. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBNamespaceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespaceListResult] + :return: An iterator like instance of either SBNamespaceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespaceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBNamespaceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SBNamespaceListResult', pipeline_response) + deserialized = self._deserialize("SBNamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -364,21 +377,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces"} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -389,44 +408,46 @@ def list_by_resource_group( :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBNamespaceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespaceListResult] + :return: An iterator like instance of either SBNamespaceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespaceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBNamespaceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SBNamespaceListResult', pipeline_response) + deserialized = self._deserialize("SBNamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -435,20 +456,25 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces"} # type: ignore async def _create_or_update_initial( self, @@ -462,39 +488,34 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBNamespace') - 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) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBNamespace') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -507,8 +528,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -527,14 +551,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either SBNamespace or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either SBNamespace or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace] + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.SBNamespace"] lro_delay = kwargs.pop( @@ -547,27 +577,22 @@ async def begin_create_or_update( resource_group_name=resource_group_name, namespace_name=namespace_name, parameters=parameters, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('SBNamespace', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -577,11 +602,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - async def _delete_initial( + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -592,41 +617,39 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + - async def begin_delete( + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -641,14 +664,17 @@ async def begin_delete( :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( @@ -660,24 +686,18 @@ async def begin_delete( raw_result = await self._delete_initial( resource_group_name=resource_group_name, namespace_name=namespace_name, + api_version=api_version, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -687,10 +707,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -713,33 +734,30 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBNamespace', pipeline_response) @@ -748,8 +766,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -776,38 +797,34 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -821,8 +838,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + + @distributed_trace def list_virtual_network_rules( self, resource_group_name: str, @@ -836,45 +856,48 @@ def list_virtual_network_rules( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VirtualNetworkRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.VirtualNetworkRuleListResult] + :return: An iterator like instance of either VirtualNetworkRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.VirtualNetworkRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetworkRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_virtual_network_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_virtual_network_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_virtual_network_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_virtual_network_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('VirtualNetworkRuleListResult', pipeline_response) + deserialized = self._deserialize("VirtualNetworkRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -883,21 +906,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_virtual_network_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules'} # type: ignore + list_virtual_network_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules"} # type: ignore + @distributed_trace_async async def create_or_update_virtual_network_rule( self, resource_group_name: str, @@ -926,39 +955,35 @@ async def create_or_update_virtual_network_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_virtual_network_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'virtualNetworkRuleName': self._serialize.url("virtual_network_rule_name", virtual_network_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'VirtualNetworkRule') - 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) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'VirtualNetworkRule') + + request = build_create_or_update_virtual_network_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + virtual_network_rule_name=virtual_network_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_virtual_network_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('VirtualNetworkRule', pipeline_response) @@ -967,9 +992,12 @@ async def create_or_update_virtual_network_rule( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_virtual_network_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules/{virtualNetworkRuleName}'} # type: ignore - async def delete_virtual_network_rule( + create_or_update_virtual_network_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules/{virtualNetworkRuleName}"} # type: ignore + + + @distributed_trace_async + async def delete_virtual_network_rule( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -994,41 +1022,40 @@ async def delete_virtual_network_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_virtual_network_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'virtualNetworkRuleName': self._serialize.url("virtual_network_rule_name", virtual_network_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_virtual_network_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + virtual_network_rule_name=virtual_network_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_virtual_network_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete_virtual_network_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules/{virtualNetworkRuleName}'} # type: ignore + delete_virtual_network_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules/{virtualNetworkRuleName}"} # type: ignore + + @distributed_trace_async async def get_virtual_network_rule( self, resource_group_name: str, @@ -1054,34 +1081,31 @@ async def get_virtual_network_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_virtual_network_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'virtualNetworkRuleName': self._serialize.url("virtual_network_rule_name", virtual_network_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_virtual_network_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + virtual_network_rule_name=virtual_network_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_virtual_network_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('VirtualNetworkRule', pipeline_response) @@ -1090,8 +1114,11 @@ async def get_virtual_network_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_virtual_network_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules/{virtualNetworkRuleName}'} # type: ignore + get_virtual_network_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules/{virtualNetworkRuleName}"} # type: ignore + + + @distributed_trace def list_authorization_rules( self, resource_group_name: str, @@ -1105,45 +1132,48 @@ def list_authorization_rules( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRuleListResult] + :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SBAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1152,21 +1182,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules"} # type: ignore + @distributed_trace_async async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -1195,39 +1231,35 @@ async def create_or_update_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBAuthorizationRule') - 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) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBAuthorizationRule') + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -1236,9 +1268,12 @@ async def create_or_update_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}'} # type: ignore - async def delete_authorization_rule( + create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace_async + async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -1263,41 +1298,40 @@ async def delete_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}'} # type: ignore + delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore + + @distributed_trace_async async def get_authorization_rule( self, resource_group_name: str, @@ -1323,34 +1357,31 @@ async def get_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -1359,8 +1390,11 @@ async def get_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}'} # type: ignore + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace_async async def list_keys( self, resource_group_name: str, @@ -1386,34 +1420,31 @@ async def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -1422,8 +1453,11 @@ async def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore + + + @distributed_trace_async async def regenerate_keys( self, resource_group_name: str, @@ -1441,7 +1475,8 @@ async def regenerate_keys( :param authorization_rule_name: The authorization rule name. :type authorization_rule_name: str :param parameters: Parameters supplied to regenerate the authorization rule. - :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.RegenerateAccessKeyParameters + :type parameters: + ~azure.mgmt.servicebus.v2018_01_01_preview.models.RegenerateAccessKeyParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessKeys, or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys @@ -1452,39 +1487,35 @@ async def regenerate_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -1493,8 +1524,11 @@ async def regenerate_keys( return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys'} # type: ignore + regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + + + @distributed_trace_async async def check_name_availability( self, parameters: "_models.CheckNameAvailability", @@ -1514,36 +1548,32 @@ async def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CheckNameAvailability') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'CheckNameAvailability') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) @@ -1552,8 +1582,11 @@ async def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability"} # type: ignore + + + @distributed_trace_async async def create_or_update_network_rule_set( self, resource_group_name: str, @@ -1579,38 +1612,34 @@ async def create_or_update_network_rule_set( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_network_rule_set.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'NetworkRuleSet') - 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) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'NetworkRuleSet') + + request = build_create_or_update_network_rule_set_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_network_rule_set.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('NetworkRuleSet', pipeline_response) @@ -1619,8 +1648,11 @@ async def create_or_update_network_rule_set( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_network_rule_set.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default'} # type: ignore + create_or_update_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore + + + @distributed_trace_async async def get_network_rule_set( self, resource_group_name: str, @@ -1643,33 +1675,30 @@ async def get_network_rule_set( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_network_rule_set.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_network_rule_set_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_network_rule_set.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('NetworkRuleSet', pipeline_response) @@ -1678,8 +1707,11 @@ async def get_network_rule_set( return cls(pipeline_response, deserialized, {}) return deserialized - get_network_rule_set.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default'} # type: ignore + get_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore + + + @distributed_trace def list_network_rule_sets( self, resource_group_name: str, @@ -1693,45 +1725,48 @@ def list_network_rule_sets( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NetworkRuleSetListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleSetListResult] + :return: An iterator like instance of either NetworkRuleSetListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkRuleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_network_rule_sets.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_network_rule_sets_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_network_rule_sets.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_network_rule_sets_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('NetworkRuleSetListResult', pipeline_response) + deserialized = self._deserialize("NetworkRuleSetListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1740,22 +1775,28 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_network_rule_sets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets'} # type: ignore + list_network_rule_sets.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets"} # type: ignore - async def migrate( + @distributed_trace_async + async def migrate( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -1780,41 +1821,38 @@ async def migrate( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.migrate.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBNamespaceMigrate') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBNamespaceMigrate') + + request = build_migrate_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.migrate.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - migrate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrate'} # type: ignore + migrate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrate"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_operations.py index e39e4293a66b..a85ea39d1434 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,19 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,38 +53,40 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -89,17 +95,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.ServiceBus/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.ServiceBus/operations"} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_premium_messaging_regions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_premium_messaging_regions_operations.py index 9cc942bc5108..caef86fc74ee 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_premium_messaging_regions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_premium_messaging_regions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,19 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._premium_messaging_regions_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -48,43 +52,44 @@ def list( """Gets the available premium messaging regions for servicebus. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PremiumMessagingRegionsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.PremiumMessagingRegionsListResult] + :return: An iterator like instance of either PremiumMessagingRegionsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.PremiumMessagingRegionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.PremiumMessagingRegionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PremiumMessagingRegionsListResult', pipeline_response) + deserialized = self._deserialize("PremiumMessagingRegionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,17 +98,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/premiumMessagingRegions'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/premiumMessagingRegions"} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_private_endpoint_connections_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_private_endpoint_connections_operations.py index 116e01dd11c1..fdce75787d90 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_private_endpoint_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,19 +6,22 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._private_endpoint_connections_operations import build_create_or_update_request, build_delete_request_initial, build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +47,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name: str, @@ -56,45 +61,48 @@ def list( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateEndpointConnectionListResult] + :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PrivateEndpointConnectionListResult', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,21 +111,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections"} # type: ignore + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -147,39 +161,35 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PrivateEndpointConnection') - 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) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + namespace_name=namespace_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -192,9 +202,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - async def _delete_initial( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -206,42 +218,40 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + - async def begin_delete( + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -258,14 +268,17 @@ async def begin_delete( :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( @@ -278,25 +291,18 @@ async def begin_delete( resource_group_name=resource_group_name, namespace_name=namespace_name, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -306,10 +312,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -335,34 +342,31 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) @@ -371,4 +375,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_private_link_resources_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_private_link_resources_operations.py index 81bc552d4f69..b9638a55cd60 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_private_link_resources_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_private_link_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,16 +6,18 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._private_link_resources_operations import build_get_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +43,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -62,33 +66,30 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PrivateLinkResourcesListResult', pipeline_response) @@ -97,4 +98,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_queues_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_queues_operations.py index a1bb57addf51..adf28e82c691 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_queues_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_queues_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._queues_operations import build_create_or_update_authorization_rule_request, build_create_or_update_request, build_delete_authorization_rule_request, build_delete_request, build_get_authorization_rule_request, build_get_request, build_list_authorization_rules_request, build_list_by_namespace_request, build_list_keys_request, build_regenerate_keys_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_authorization_rules( self, resource_group_name: str, @@ -57,46 +62,50 @@ def list_authorization_rules( :param queue_name: The queue name. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRuleListResult] + :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SBAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,21 +114,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules"} # type: ignore + @distributed_trace_async async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -151,40 +166,36 @@ async def create_or_update_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBAuthorizationRule') - 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) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBAuthorizationRule') + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -193,9 +204,12 @@ async def create_or_update_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}'} # type: ignore - async def delete_authorization_rule( + create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace_async + async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -223,42 +237,41 @@ async def delete_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}'} # type: ignore + delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + @distributed_trace_async async def get_authorization_rule( self, resource_group_name: str, @@ -287,35 +300,32 @@ async def get_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -324,8 +334,11 @@ async def get_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}'} # type: ignore + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace_async async def list_keys( self, resource_group_name: str, @@ -354,35 +367,32 @@ async def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -391,8 +401,11 @@ async def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore + + + @distributed_trace_async async def regenerate_keys( self, resource_group_name: str, @@ -413,7 +426,8 @@ async def regenerate_keys( :param authorization_rule_name: The authorization rule name. :type authorization_rule_name: str :param parameters: Parameters supplied to regenerate the authorization rule. - :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.RegenerateAccessKeyParameters + :type parameters: + ~azure.mgmt.servicebus.v2018_01_01_preview.models.RegenerateAccessKeyParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessKeys, or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys @@ -424,40 +438,36 @@ async def regenerate_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -466,8 +476,11 @@ async def regenerate_keys( return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys'} # type: ignore + regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + + + @distributed_trace def list_by_namespace( self, resource_group_name: str, @@ -484,54 +497,57 @@ def list_by_namespace( :type namespace_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. + parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip: int :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SBQueueListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBQueueListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBQueueListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBQueueListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_namespace.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', maximum=1000, minimum=0) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=self.list_by_namespace.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SBQueueListResult', pipeline_response) + deserialized = self._deserialize("SBQueueListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -540,21 +556,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_namespace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues'} # type: ignore + list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues"} # type: ignore + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -583,39 +605,35 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBQueue') - 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) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBQueue') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBQueue', pipeline_response) @@ -624,9 +642,12 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}'} # type: ignore - async def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -651,41 +672,40 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -711,34 +731,31 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBQueue', pipeline_response) @@ -747,4 +764,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_regions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_regions_operations.py index d66ac64fac84..6f54673bc301 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_regions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_regions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,19 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._regions_operations import build_list_by_sku_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_sku( self, sku: str, @@ -51,44 +55,46 @@ def list_by_sku( :param sku: The sku type. :type sku: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PremiumMessagingRegionsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.PremiumMessagingRegionsListResult] + :return: An iterator like instance of either PremiumMessagingRegionsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.PremiumMessagingRegionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.PremiumMessagingRegionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_sku.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'sku': self._serialize.url("sku", sku, 'str', max_length=50, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_sku_request( + subscription_id=self._config.subscription_id, + sku=sku, + api_version=api_version, + template_url=self.list_by_sku.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_sku_request( + subscription_id=self._config.subscription_id, + sku=sku, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PremiumMessagingRegionsListResult', pipeline_response) + deserialized = self._deserialize("PremiumMessagingRegionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -97,17 +103,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_sku.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/sku/{sku}/regions'} # type: ignore + list_by_sku.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/sku/{sku}/regions"} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_rules_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_rules_operations.py index 23ebdb5d088f..365462919e48 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_rules_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_rules_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._rules_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_subscriptions_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_subscriptions( self, resource_group_name: str, @@ -63,56 +68,61 @@ def list_by_subscriptions( :type subscription_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. + parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip: int :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.RuleListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.RuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscriptions.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', maximum=1000, minimum=0) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscriptions_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=self.list_by_subscriptions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscriptions_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RuleListResult', pipeline_response) + deserialized = self._deserialize("RuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -121,21 +131,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_subscriptions.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules'} # type: ignore + list_by_subscriptions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules"} # type: ignore + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -170,41 +186,37 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Rule') - 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) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Rule') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Rule', pipeline_response) @@ -213,9 +225,12 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}'} # type: ignore - async def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -246,43 +261,42 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -314,36 +328,33 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Rule', pipeline_response) @@ -352,4 +363,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_subscriptions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_subscriptions_operations.py index 009e1fabce40..8a29497942bc 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_subscriptions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_subscriptions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._subscriptions_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_topic_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_topic( self, resource_group_name: str, @@ -60,55 +65,60 @@ def list_by_topic( :type topic_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. + parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip: int :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBSubscriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSubscriptionListResult] + :return: An iterator like instance of either SBSubscriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSubscriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBSubscriptionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_topic.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', maximum=1000, minimum=0) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_topic_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=self.list_by_topic.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_topic_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SBSubscriptionListResult', pipeline_response) + deserialized = self._deserialize("SBSubscriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -117,21 +127,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_topic.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions'} # type: ignore + list_by_topic.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions"} # type: ignore + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -163,40 +179,36 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBSubscription') - 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) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBSubscription') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBSubscription', pipeline_response) @@ -205,9 +217,12 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}'} # type: ignore - async def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -235,42 +250,41 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -299,35 +313,32 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBSubscription', pipeline_response) @@ -336,4 +347,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_topics_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_topics_operations.py index 59854f70f658..7048a7987525 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_topics_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_topics_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._topics_operations import build_create_or_update_authorization_rule_request, build_create_or_update_request, build_delete_authorization_rule_request, build_delete_request, build_get_authorization_rule_request, build_get_request, build_list_authorization_rules_request, build_list_by_namespace_request, build_list_keys_request, build_regenerate_keys_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_authorization_rules( self, resource_group_name: str, @@ -57,46 +62,50 @@ def list_authorization_rules( :param topic_name: The topic name. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRuleListResult] + :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SBAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,21 +114,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules"} # type: ignore + @distributed_trace_async async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -151,40 +166,36 @@ async def create_or_update_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBAuthorizationRule') - 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) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBAuthorizationRule') + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -193,8 +204,11 @@ async def create_or_update_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}'} # type: ignore + create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace_async async def get_authorization_rule( self, resource_group_name: str, @@ -223,35 +237,32 @@ async def get_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -260,9 +271,12 @@ async def get_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}'} # type: ignore - async def delete_authorization_rule( + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace_async + async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -290,42 +304,41 @@ async def delete_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}'} # type: ignore + delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + @distributed_trace_async async def list_keys( self, resource_group_name: str, @@ -354,35 +367,32 @@ async def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -391,8 +401,11 @@ async def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore + + + @distributed_trace_async async def regenerate_keys( self, resource_group_name: str, @@ -413,7 +426,8 @@ async def regenerate_keys( :param authorization_rule_name: The authorization rule name. :type authorization_rule_name: str :param parameters: Parameters supplied to regenerate the authorization rule. - :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.RegenerateAccessKeyParameters + :type parameters: + ~azure.mgmt.servicebus.v2018_01_01_preview.models.RegenerateAccessKeyParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessKeys, or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys @@ -424,40 +438,36 @@ async def regenerate_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -466,8 +476,11 @@ async def regenerate_keys( return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys'} # type: ignore + regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + + + @distributed_trace def list_by_namespace( self, resource_group_name: str, @@ -484,54 +497,57 @@ def list_by_namespace( :type namespace_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. + parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip: int :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SBTopicListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBTopicListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBTopicListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBTopicListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_namespace.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', maximum=1000, minimum=0) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=self.list_by_namespace.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SBTopicListResult', pipeline_response) + deserialized = self._deserialize("SBTopicListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -540,21 +556,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_namespace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics'} # type: ignore + list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics"} # type: ignore + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -583,39 +605,35 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBTopic') - 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) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBTopic') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBTopic', pipeline_response) @@ -624,9 +642,12 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}'} # type: ignore - async def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -651,41 +672,40 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -711,34 +731,31 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBTopic', pipeline_response) @@ -747,4 +764,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/models/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/models/__init__.py index 2297b182a4e2..c3a8a50a61b6 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/models/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/models/__init__.py @@ -6,134 +6,70 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import AccessKeys - from ._models_py3 import Action - from ._models_py3 import ArmDisasterRecovery - from ._models_py3 import ArmDisasterRecoveryListResult - from ._models_py3 import CaptureDescription - from ._models_py3 import CheckNameAvailability - from ._models_py3 import CheckNameAvailabilityResult - from ._models_py3 import ConnectionState - from ._models_py3 import CorrelationFilter - from ._models_py3 import Destination - from ._models_py3 import Encryption - from ._models_py3 import ErrorAdditionalInfo - from ._models_py3 import ErrorResponse - from ._models_py3 import ErrorResponseError - from ._models_py3 import EventHubListResult - from ._models_py3 import Eventhub - from ._models_py3 import FailoverProperties - from ._models_py3 import Identity - from ._models_py3 import IpFilterRule - from ._models_py3 import IpFilterRuleListResult - from ._models_py3 import KeyVaultProperties - from ._models_py3 import MessageCountDetails - from ._models_py3 import MigrationConfigListResult - from ._models_py3 import MigrationConfigProperties - from ._models_py3 import NWRuleSetIpRules - from ._models_py3 import NWRuleSetVirtualNetworkRules - from ._models_py3 import NetworkRuleSet - from ._models_py3 import NetworkRuleSetListResult - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationListResult - from ._models_py3 import PremiumMessagingRegions - from ._models_py3 import PremiumMessagingRegionsListResult - from ._models_py3 import PremiumMessagingRegionsProperties - from ._models_py3 import PrivateEndpoint - from ._models_py3 import PrivateEndpointConnection - from ._models_py3 import PrivateEndpointConnectionListResult - from ._models_py3 import PrivateLinkResource - from ._models_py3 import PrivateLinkResourcesListResult - from ._models_py3 import RegenerateAccessKeyParameters - from ._models_py3 import Resource - from ._models_py3 import ResourceNamespacePatch - from ._models_py3 import Rule - from ._models_py3 import RuleListResult - from ._models_py3 import SBAuthorizationRule - from ._models_py3 import SBAuthorizationRuleListResult - from ._models_py3 import SBNamespace - from ._models_py3 import SBNamespaceListResult - from ._models_py3 import SBNamespaceMigrate - from ._models_py3 import SBNamespaceUpdateParameters - from ._models_py3 import SBQueue - from ._models_py3 import SBQueueListResult - from ._models_py3 import SBSku - from ._models_py3 import SBSubscription - from ._models_py3 import SBSubscriptionListResult - from ._models_py3 import SBTopic - from ._models_py3 import SBTopicListResult - from ._models_py3 import SqlFilter - from ._models_py3 import SqlRuleAction - from ._models_py3 import Subnet - from ._models_py3 import TrackedResource - from ._models_py3 import VirtualNetworkRule - from ._models_py3 import VirtualNetworkRuleListResult -except (SyntaxError, ImportError): - from ._models import AccessKeys # type: ignore - from ._models import Action # type: ignore - from ._models import ArmDisasterRecovery # type: ignore - from ._models import ArmDisasterRecoveryListResult # type: ignore - from ._models import CaptureDescription # type: ignore - from ._models import CheckNameAvailability # type: ignore - from ._models import CheckNameAvailabilityResult # type: ignore - from ._models import ConnectionState # type: ignore - from ._models import CorrelationFilter # type: ignore - from ._models import Destination # type: ignore - from ._models import Encryption # type: ignore - from ._models import ErrorAdditionalInfo # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import ErrorResponseError # type: ignore - from ._models import EventHubListResult # type: ignore - from ._models import Eventhub # type: ignore - from ._models import FailoverProperties # type: ignore - from ._models import Identity # type: ignore - from ._models import IpFilterRule # type: ignore - from ._models import IpFilterRuleListResult # type: ignore - from ._models import KeyVaultProperties # type: ignore - from ._models import MessageCountDetails # type: ignore - from ._models import MigrationConfigListResult # type: ignore - from ._models import MigrationConfigProperties # type: ignore - from ._models import NWRuleSetIpRules # type: ignore - from ._models import NWRuleSetVirtualNetworkRules # type: ignore - from ._models import NetworkRuleSet # type: ignore - from ._models import NetworkRuleSetListResult # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import PremiumMessagingRegions # type: ignore - from ._models import PremiumMessagingRegionsListResult # type: ignore - from ._models import PremiumMessagingRegionsProperties # type: ignore - from ._models import PrivateEndpoint # type: ignore - from ._models import PrivateEndpointConnection # type: ignore - from ._models import PrivateEndpointConnectionListResult # type: ignore - from ._models import PrivateLinkResource # type: ignore - from ._models import PrivateLinkResourcesListResult # type: ignore - from ._models import RegenerateAccessKeyParameters # type: ignore - from ._models import Resource # type: ignore - from ._models import ResourceNamespacePatch # type: ignore - from ._models import Rule # type: ignore - from ._models import RuleListResult # type: ignore - from ._models import SBAuthorizationRule # type: ignore - from ._models import SBAuthorizationRuleListResult # type: ignore - from ._models import SBNamespace # type: ignore - from ._models import SBNamespaceListResult # type: ignore - from ._models import SBNamespaceMigrate # type: ignore - from ._models import SBNamespaceUpdateParameters # type: ignore - from ._models import SBQueue # type: ignore - from ._models import SBQueueListResult # type: ignore - from ._models import SBSku # type: ignore - from ._models import SBSubscription # type: ignore - from ._models import SBSubscriptionListResult # type: ignore - from ._models import SBTopic # type: ignore - from ._models import SBTopicListResult # type: ignore - from ._models import SqlFilter # type: ignore - from ._models import SqlRuleAction # type: ignore - from ._models import Subnet # type: ignore - from ._models import TrackedResource # type: ignore - from ._models import VirtualNetworkRule # type: ignore - from ._models import VirtualNetworkRuleListResult # type: ignore +from ._models_py3 import AccessKeys +from ._models_py3 import Action +from ._models_py3 import ArmDisasterRecovery +from ._models_py3 import ArmDisasterRecoveryListResult +from ._models_py3 import CaptureDescription +from ._models_py3 import CheckNameAvailability +from ._models_py3 import CheckNameAvailabilityResult +from ._models_py3 import ConnectionState +from ._models_py3 import CorrelationFilter +from ._models_py3 import Destination +from ._models_py3 import Encryption +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorResponse +from ._models_py3 import ErrorResponseError +from ._models_py3 import EventHubListResult +from ._models_py3 import Eventhub +from ._models_py3 import FailoverProperties +from ._models_py3 import Identity +from ._models_py3 import IpFilterRule +from ._models_py3 import IpFilterRuleListResult +from ._models_py3 import KeyVaultProperties +from ._models_py3 import MessageCountDetails +from ._models_py3 import MigrationConfigListResult +from ._models_py3 import MigrationConfigProperties +from ._models_py3 import NWRuleSetIpRules +from ._models_py3 import NWRuleSetVirtualNetworkRules +from ._models_py3 import NetworkRuleSet +from ._models_py3 import NetworkRuleSetListResult +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import PremiumMessagingRegions +from ._models_py3 import PremiumMessagingRegionsListResult +from ._models_py3 import PremiumMessagingRegionsProperties +from ._models_py3 import PrivateEndpoint +from ._models_py3 import PrivateEndpointConnection +from ._models_py3 import PrivateEndpointConnectionListResult +from ._models_py3 import PrivateLinkResource +from ._models_py3 import PrivateLinkResourcesListResult +from ._models_py3 import RegenerateAccessKeyParameters +from ._models_py3 import Resource +from ._models_py3 import ResourceNamespacePatch +from ._models_py3 import Rule +from ._models_py3 import RuleListResult +from ._models_py3 import SBAuthorizationRule +from ._models_py3 import SBAuthorizationRuleListResult +from ._models_py3 import SBNamespace +from ._models_py3 import SBNamespaceListResult +from ._models_py3 import SBNamespaceMigrate +from ._models_py3 import SBNamespaceUpdateParameters +from ._models_py3 import SBQueue +from ._models_py3 import SBQueueListResult +from ._models_py3 import SBSku +from ._models_py3 import SBSubscription +from ._models_py3 import SBSubscriptionListResult +from ._models_py3 import SBTopic +from ._models_py3 import SBTopicListResult +from ._models_py3 import SqlFilter +from ._models_py3 import SqlRuleAction +from ._models_py3 import Subnet +from ._models_py3 import TrackedResource +from ._models_py3 import VirtualNetworkRule +from ._models_py3 import VirtualNetworkRuleListResult + from ._service_bus_management_client_enums import ( AccessRights, diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/models/_models.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/models/_models.py deleted file mode 100644 index ec2121970f1d..000000000000 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/models/_models.py +++ /dev/null @@ -1,2499 +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 azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class AccessKeys(msrest.serialization.Model): - """Namespace/ServiceBus Connection String. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar primary_connection_string: Primary connection string of the created namespace - authorization rule. - :vartype primary_connection_string: str - :ivar secondary_connection_string: Secondary connection string of the created namespace - authorization rule. - :vartype secondary_connection_string: str - :ivar alias_primary_connection_string: Primary connection string of the alias if GEO DR is - enabled. - :vartype alias_primary_connection_string: str - :ivar alias_secondary_connection_string: Secondary connection string of the alias if GEO DR is - enabled. - :vartype alias_secondary_connection_string: str - :ivar primary_key: A base64-encoded 256-bit primary key for signing and validating the SAS - token. - :vartype primary_key: str - :ivar secondary_key: A base64-encoded 256-bit primary key for signing and validating the SAS - token. - :vartype secondary_key: str - :ivar key_name: A string that describes the authorization rule. - :vartype key_name: str - """ - - _validation = { - 'primary_connection_string': {'readonly': True}, - 'secondary_connection_string': {'readonly': True}, - 'alias_primary_connection_string': {'readonly': True}, - 'alias_secondary_connection_string': {'readonly': True}, - 'primary_key': {'readonly': True}, - 'secondary_key': {'readonly': True}, - 'key_name': {'readonly': True}, - } - - _attribute_map = { - 'primary_connection_string': {'key': 'primaryConnectionString', 'type': 'str'}, - 'secondary_connection_string': {'key': 'secondaryConnectionString', 'type': 'str'}, - 'alias_primary_connection_string': {'key': 'aliasPrimaryConnectionString', 'type': 'str'}, - 'alias_secondary_connection_string': {'key': 'aliasSecondaryConnectionString', 'type': 'str'}, - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, - 'key_name': {'key': 'keyName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AccessKeys, self).__init__(**kwargs) - self.primary_connection_string = None - self.secondary_connection_string = None - self.alias_primary_connection_string = None - self.alias_secondary_connection_string = None - self.primary_key = None - self.secondary_key = None - self.key_name = None - - -class Action(msrest.serialization.Model): - """Represents the filter actions which are allowed for the transformation of a message that have been matched by a filter expression. - - :param sql_expression: SQL expression. e.g. MyProperty='ABC'. - :type sql_expression: str - :param compatibility_level: This property is reserved for future use. An integer value showing - the compatibility level, currently hard-coded to 20. - :type compatibility_level: int - :param requires_preprocessing: Value that indicates whether the rule action requires - preprocessing. - :type requires_preprocessing: bool - """ - - _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(Action, self).__init__(**kwargs) - self.sql_expression = kwargs.get('sql_expression', None) - self.compatibility_level = kwargs.get('compatibility_level', None) - self.requires_preprocessing = kwargs.get('requires_preprocessing', True) - - -class Resource(msrest.serialization.Model): - """The Resource definition for other than namespace. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class ArmDisasterRecovery(Resource): - """Single item in List or Get Alias(Disaster Recovery configuration) operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar provisioning_state: Provisioning state of the Alias(Disaster Recovery configuration) - - possible values 'Accepted' or 'Succeeded' or 'Failed'. Possible values include: "Accepted", - "Succeeded", "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.servicebus.v2018_01_01_preview.models.ProvisioningStateDR - :ivar pending_replication_operations_count: Number of entities pending to be replicated. - :vartype pending_replication_operations_count: long - :param partner_namespace: ARM Id of the Primary/Secondary eventhub namespace name, which is - part of GEO DR pairing. - :type partner_namespace: str - :param alternate_name: Primary/Secondary eventhub namespace name, which is part of GEO DR - pairing. - :type alternate_name: str - :ivar role: role of namespace in GEO DR - possible values 'Primary' or 'PrimaryNotReplicating' - or 'Secondary'. Possible values include: "Primary", "PrimaryNotReplicating", "Secondary". - :vartype role: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.RoleDisasterRecovery - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'pending_replication_operations_count': {'readonly': True}, - 'role': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'pending_replication_operations_count': {'key': 'properties.pendingReplicationOperationsCount', 'type': 'long'}, - 'partner_namespace': {'key': 'properties.partnerNamespace', 'type': 'str'}, - 'alternate_name': {'key': 'properties.alternateName', 'type': 'str'}, - 'role': {'key': 'properties.role', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ArmDisasterRecovery, self).__init__(**kwargs) - self.provisioning_state = None - self.pending_replication_operations_count = None - self.partner_namespace = kwargs.get('partner_namespace', None) - self.alternate_name = kwargs.get('alternate_name', None) - self.role = None - - -class ArmDisasterRecoveryListResult(msrest.serialization.Model): - """The result of the List Alias(Disaster Recovery configuration) operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: List of Alias(Disaster Recovery configurations). - :type value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.ArmDisasterRecovery] - :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list - of Alias(Disaster Recovery configuration). - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ArmDisasterRecovery]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ArmDisasterRecoveryListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class CaptureDescription(msrest.serialization.Model): - """Properties to configure capture description for eventhub. - - :param enabled: A value that indicates whether capture description is enabled. - :type enabled: bool - :param encoding: Enumerates the possible values for the encoding format of capture description. - Possible values include: "Avro", "AvroDeflate". - :type encoding: str or - ~azure.mgmt.servicebus.v2018_01_01_preview.models.EncodingCaptureDescription - :param interval_in_seconds: The time window allows you to set the frequency with which the - capture to Azure Blobs will happen, value should between 60 to 900 seconds. - :type interval_in_seconds: int - :param size_limit_in_bytes: The size window defines the amount of data built up in your Event - Hub before an capture operation, value should be between 10485760 and 524288000 bytes. - :type size_limit_in_bytes: int - :param destination: Properties of Destination where capture will be stored. (Storage Account, - Blob Names). - :type destination: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Destination - """ - - _validation = { - 'interval_in_seconds': {'maximum': 900, 'minimum': 60}, - 'size_limit_in_bytes': {'maximum': 524288000, 'minimum': 10485760}, - } - - _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'encoding': {'key': 'encoding', 'type': 'str'}, - 'interval_in_seconds': {'key': 'intervalInSeconds', 'type': 'int'}, - 'size_limit_in_bytes': {'key': 'sizeLimitInBytes', 'type': 'int'}, - 'destination': {'key': 'destination', 'type': 'Destination'}, - } - - def __init__( - self, - **kwargs - ): - super(CaptureDescription, self).__init__(**kwargs) - self.enabled = kwargs.get('enabled', None) - self.encoding = kwargs.get('encoding', None) - self.interval_in_seconds = kwargs.get('interval_in_seconds', None) - self.size_limit_in_bytes = kwargs.get('size_limit_in_bytes', None) - self.destination = kwargs.get('destination', None) - - -class CheckNameAvailability(msrest.serialization.Model): - """Description of a Check Name availability request properties. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The Name to check the namespace name availability and The namespace name - can contain only letters, numbers, and hyphens. The namespace must start with a letter, and it - must end with a letter or number. - :type name: str - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CheckNameAvailability, self).__init__(**kwargs) - self.name = kwargs['name'] - - -class CheckNameAvailabilityResult(msrest.serialization.Model): - """Description of a Check Name availability request properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar message: The detailed info regarding the reason associated with the namespace. - :vartype message: str - :param name_available: Value indicating namespace is availability, true if the namespace is - available; otherwise, false. - :type name_available: bool - :param reason: The reason for unavailability of a namespace. Possible values include: "None", - "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", - "TooManyNamespaceInCurrentSubscription". - :type reason: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.UnavailableReason - """ - - _validation = { - 'message': {'readonly': True}, - } - - _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CheckNameAvailabilityResult, self).__init__(**kwargs) - self.message = None - self.name_available = kwargs.get('name_available', None) - self.reason = kwargs.get('reason', None) - - -class ConnectionState(msrest.serialization.Model): - """ConnectionState information. - - :param status: Status of the connection. Possible values include: "Pending", "Approved", - "Rejected", "Disconnected". - :type status: str or - ~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateLinkConnectionStatus - :param description: Description of the connection state. - :type description: str - """ - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ConnectionState, self).__init__(**kwargs) - self.status = kwargs.get('status', None) - self.description = kwargs.get('description', None) - - -class CorrelationFilter(msrest.serialization.Model): - """Represents the correlation filter expression. - - :param properties: dictionary object for custom filters. - :type properties: dict[str, str] - :param correlation_id: Identifier of the correlation. - :type correlation_id: str - :param message_id: Identifier of the message. - :type message_id: str - :param to: Address to send to. - :type to: str - :param reply_to: Address of the queue to reply to. - :type reply_to: str - :param label: Application specific label. - :type label: str - :param session_id: Session identifier. - :type session_id: str - :param reply_to_session_id: Session identifier to reply to. - :type reply_to_session_id: str - :param content_type: Content type of the message. - :type content_type: str - :param requires_preprocessing: Value that indicates whether the rule action requires - preprocessing. - :type requires_preprocessing: bool - """ - - _attribute_map = { - 'properties': {'key': 'properties', 'type': '{str}'}, - 'correlation_id': {'key': 'correlationId', 'type': 'str'}, - 'message_id': {'key': 'messageId', 'type': 'str'}, - 'to': {'key': 'to', 'type': 'str'}, - 'reply_to': {'key': 'replyTo', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'session_id': {'key': 'sessionId', 'type': 'str'}, - 'reply_to_session_id': {'key': 'replyToSessionId', 'type': 'str'}, - 'content_type': {'key': 'contentType', 'type': 'str'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(CorrelationFilter, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - 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.requires_preprocessing = kwargs.get('requires_preprocessing', True) - - -class Destination(msrest.serialization.Model): - """Capture storage details for capture description. - - :param name: Name for capture destination. - :type name: str - :param storage_account_resource_id: Resource id of the storage account to be used to create the - blobs. - :type storage_account_resource_id: str - :param blob_container: Blob container Name. - :type blob_container: str - :param archive_name_format: Blob naming convention for archive, e.g. - {Namespace}/{EventHub}/{PartitionId}/{Year}/{Month}/{Day}/{Hour}/{Minute}/{Second}. Here all - the parameters (Namespace,EventHub .. etc) are mandatory irrespective of order. - :type archive_name_format: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'storage_account_resource_id': {'key': 'properties.storageAccountResourceId', 'type': 'str'}, - 'blob_container': {'key': 'properties.blobContainer', 'type': 'str'}, - 'archive_name_format': {'key': 'properties.archiveNameFormat', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Destination, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.storage_account_resource_id = kwargs.get('storage_account_resource_id', None) - self.blob_container = kwargs.get('blob_container', None) - self.archive_name_format = kwargs.get('archive_name_format', None) - - -class Encryption(msrest.serialization.Model): - """Properties to configure Encryption. - - :param key_vault_properties: Properties of KeyVault. - :type key_vault_properties: - ~azure.mgmt.servicebus.v2018_01_01_preview.models.KeyVaultProperties - :param key_source: Enumerates the possible value of keySource for Encryption. The only - acceptable values to pass in are None and "Microsoft.KeyVault". The default value is - "Microsoft.KeyVault". - :type key_source: str - """ - - _attribute_map = { - 'key_vault_properties': {'key': 'keyVaultProperties', 'type': 'KeyVaultProperties'}, - 'key_source': {'key': 'keySource', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Encryption, self).__init__(**kwargs) - self.key_vault_properties = kwargs.get('key_vault_properties', None) - self.key_source = kwargs.get('key_source', "Microsoft.KeyVault") - - -class ErrorAdditionalInfo(msrest.serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: any - """ - - _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorAdditionalInfo, self).__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorResponse(msrest.serialization.Model): - """The resource management error response. - - :param error: The error object. - :type error: ~azure.mgmt.servicebus.v2018_01_01_preview.models.ErrorResponseError - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseError'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class ErrorResponseError(msrest.serialization.Model): - """The error object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.ErrorResponse] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.servicebus.v2018_01_01_preview.models.ErrorAdditionalInfo] - """ - - _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponseError, self).__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class Eventhub(Resource): - """Single item in List or Get Event Hub operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar partition_ids: Current number of shards on the Event Hub. - :vartype partition_ids: list[str] - :ivar created_at: Exact time the Event Hub was created. - :vartype created_at: ~datetime.datetime - :ivar updated_at: The exact time the message was updated. - :vartype updated_at: ~datetime.datetime - :param message_retention_in_days: Number of days to retain the events for this Event Hub, value - should be 1 to 7 days. - :type message_retention_in_days: long - :param partition_count: Number of partitions created for the Event Hub, allowed values are from - 1 to 32 partitions. - :type partition_count: long - :param status: Enumerates the possible values for the status of a Event Hub. Possible values - include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". - :type status: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.EntityStatus - :param capture_description: Properties of capture description. - :type capture_description: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CaptureDescription - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'partition_ids': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'message_retention_in_days': {'maximum': 7, 'minimum': 1}, - 'partition_count': {'maximum': 32, 'minimum': 1}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'partition_ids': {'key': 'properties.partitionIds', 'type': '[str]'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'message_retention_in_days': {'key': 'properties.messageRetentionInDays', 'type': 'long'}, - 'partition_count': {'key': 'properties.partitionCount', 'type': 'long'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'capture_description': {'key': 'properties.captureDescription', 'type': 'CaptureDescription'}, - } - - def __init__( - self, - **kwargs - ): - super(Eventhub, self).__init__(**kwargs) - self.partition_ids = None - self.created_at = None - self.updated_at = None - self.message_retention_in_days = kwargs.get('message_retention_in_days', None) - self.partition_count = kwargs.get('partition_count', None) - self.status = kwargs.get('status', None) - self.capture_description = kwargs.get('capture_description', None) - - -class EventHubListResult(msrest.serialization.Model): - """The result of the List EventHubs operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: Result of the List EventHubs operation. - :type value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.Eventhub] - :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list - of EventHubs. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Eventhub]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EventHubListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class FailoverProperties(msrest.serialization.Model): - """Safe failover is to indicate the service should wait for pending replication to finish before switching to the secondary. - - :param is_safe_failover: Safe failover is to indicate the service should wait for pending - replication to finish before switching to the secondary. - :type is_safe_failover: bool - """ - - _attribute_map = { - 'is_safe_failover': {'key': 'properties.IsSafeFailover', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(FailoverProperties, self).__init__(**kwargs) - self.is_safe_failover = kwargs.get('is_safe_failover', None) - - -class Identity(msrest.serialization.Model): - """Properties to configure Identity for Bring your Own Keys. - - :param principal_id: ObjectId from the KeyVault. - :type principal_id: str - :param tenant_id: TenantId from the KeyVault. - :type tenant_id: str - :param type: Enumerates the possible value Identity type, which currently supports only - 'SystemAssigned'. The only acceptable values to pass in are None and "SystemAssigned". The - default value is "SystemAssigned". - :type type: str - """ - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Identity, self).__init__(**kwargs) - self.principal_id = kwargs.get('principal_id', None) - self.tenant_id = kwargs.get('tenant_id', None) - self.type = kwargs.get('type', "SystemAssigned") - - -class IpFilterRule(Resource): - """Single item in a List or Get IpFilterRules operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param ip_mask: IP Mask. - :type ip_mask: str - :param action: The IP Filter Action. Possible values include: "Accept", "Reject". - :type action: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.IPAction - :param filter_name: IP Filter name. - :type filter_name: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'ip_mask': {'key': 'properties.ipMask', 'type': 'str'}, - 'action': {'key': 'properties.action', 'type': 'str'}, - 'filter_name': {'key': 'properties.filterName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IpFilterRule, self).__init__(**kwargs) - self.ip_mask = kwargs.get('ip_mask', None) - self.action = kwargs.get('action', None) - self.filter_name = kwargs.get('filter_name', None) - - -class IpFilterRuleListResult(msrest.serialization.Model): - """The response from the List namespace operation. - - :param value: Result of the List IpFilter Rules operation. - :type value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.IpFilterRule] - :param next_link: Link to the next set of results. Not empty if Value contains an incomplete - list of IpFilter Rules. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[IpFilterRule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IpFilterRuleListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class KeyVaultProperties(msrest.serialization.Model): - """Properties to configure keyVault Properties. - - :param key_name: Name of the Key from KeyVault. - :type key_name: str - :param key_vault_uri: Uri of KeyVault. - :type key_vault_uri: str - """ - - _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'key_vault_uri': {'key': 'keyVaultUri', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(KeyVaultProperties, self).__init__(**kwargs) - self.key_name = kwargs.get('key_name', None) - self.key_vault_uri = kwargs.get('key_vault_uri', None) - - -class MessageCountDetails(msrest.serialization.Model): - """Message Count Details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar active_message_count: Number of active messages in the queue, topic, or subscription. - :vartype active_message_count: long - :ivar dead_letter_message_count: Number of messages that are dead lettered. - :vartype dead_letter_message_count: long - :ivar scheduled_message_count: Number of scheduled messages. - :vartype scheduled_message_count: long - :ivar transfer_message_count: Number of messages transferred to another queue, topic, or - subscription. - :vartype transfer_message_count: long - :ivar transfer_dead_letter_message_count: Number of messages transferred into dead letters. - :vartype transfer_dead_letter_message_count: long - """ - - _validation = { - 'active_message_count': {'readonly': True}, - 'dead_letter_message_count': {'readonly': True}, - 'scheduled_message_count': {'readonly': True}, - 'transfer_message_count': {'readonly': True}, - 'transfer_dead_letter_message_count': {'readonly': True}, - } - - _attribute_map = { - 'active_message_count': {'key': 'activeMessageCount', 'type': 'long'}, - 'dead_letter_message_count': {'key': 'deadLetterMessageCount', 'type': 'long'}, - 'scheduled_message_count': {'key': 'scheduledMessageCount', 'type': 'long'}, - 'transfer_message_count': {'key': 'transferMessageCount', 'type': 'long'}, - 'transfer_dead_letter_message_count': {'key': 'transferDeadLetterMessageCount', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(MessageCountDetails, self).__init__(**kwargs) - self.active_message_count = None - self.dead_letter_message_count = None - self.scheduled_message_count = None - self.transfer_message_count = None - self.transfer_dead_letter_message_count = None - - -class MigrationConfigListResult(msrest.serialization.Model): - """The result of the List migrationConfigurations operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: List of Migration Configs. - :type value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigProperties] - :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list - of migrationConfigurations. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[MigrationConfigProperties]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MigrationConfigListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class MigrationConfigProperties(Resource): - """Single item in List or Get Migration Config operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar provisioning_state: Provisioning state of Migration Configuration. - :vartype provisioning_state: str - :ivar pending_replication_operations_count: Number of entities pending to be replicated. - :vartype pending_replication_operations_count: long - :param target_namespace: Existing premium Namespace ARM Id name which has no entities, will be - used for migration. - :type target_namespace: str - :param post_migration_name: Name to access Standard Namespace after migration. - :type post_migration_name: str - :ivar migration_state: State in which Standard to Premium Migration is, possible values : - Unknown, Reverting, Completing, Initiating, Syncing, Active. - :vartype migration_state: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'pending_replication_operations_count': {'readonly': True}, - 'migration_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'pending_replication_operations_count': {'key': 'properties.pendingReplicationOperationsCount', 'type': 'long'}, - 'target_namespace': {'key': 'properties.targetNamespace', 'type': 'str'}, - 'post_migration_name': {'key': 'properties.postMigrationName', 'type': 'str'}, - 'migration_state': {'key': 'properties.migrationState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MigrationConfigProperties, self).__init__(**kwargs) - self.provisioning_state = None - self.pending_replication_operations_count = None - self.target_namespace = kwargs.get('target_namespace', None) - self.post_migration_name = kwargs.get('post_migration_name', None) - self.migration_state = None - - -class NetworkRuleSet(Resource): - """Description of NetworkRuleSet resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param default_action: Default Action for Network Rule Set. Possible values include: "Allow", - "Deny". - :type default_action: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.DefaultAction - :param virtual_network_rules: List VirtualNetwork Rules. - :type virtual_network_rules: - list[~azure.mgmt.servicebus.v2018_01_01_preview.models.NWRuleSetVirtualNetworkRules] - :param ip_rules: List of IpRules. - :type ip_rules: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.NWRuleSetIpRules] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'default_action': {'key': 'properties.defaultAction', 'type': 'str'}, - 'virtual_network_rules': {'key': 'properties.virtualNetworkRules', 'type': '[NWRuleSetVirtualNetworkRules]'}, - 'ip_rules': {'key': 'properties.ipRules', 'type': '[NWRuleSetIpRules]'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkRuleSet, self).__init__(**kwargs) - self.default_action = kwargs.get('default_action', None) - self.virtual_network_rules = kwargs.get('virtual_network_rules', None) - self.ip_rules = kwargs.get('ip_rules', None) - - -class NetworkRuleSetListResult(msrest.serialization.Model): - """The response of the List NetworkRuleSet operation. - - :param value: Result of the List NetworkRuleSet operation. - :type value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleSet] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list - of NetworkRuleSet. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[NetworkRuleSet]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkRuleSetListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class NWRuleSetIpRules(msrest.serialization.Model): - """Description of NetWorkRuleSet - IpRules resource. - - :param ip_mask: IP Mask. - :type ip_mask: str - :param action: The IP Filter Action. Possible values include: "Allow". Default value: "Allow". - :type action: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleIPAction - """ - - _attribute_map = { - 'ip_mask': {'key': 'ipMask', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NWRuleSetIpRules, self).__init__(**kwargs) - self.ip_mask = kwargs.get('ip_mask', None) - self.action = kwargs.get('action', "Allow") - - -class NWRuleSetVirtualNetworkRules(msrest.serialization.Model): - """Description of VirtualNetworkRules - NetworkRules resource. - - :param subnet: Subnet properties. - :type subnet: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Subnet - :param ignore_missing_vnet_service_endpoint: Value that indicates whether to ignore missing - VNet Service Endpoint. - :type ignore_missing_vnet_service_endpoint: bool - """ - - _attribute_map = { - 'subnet': {'key': 'subnet', 'type': 'Subnet'}, - 'ignore_missing_vnet_service_endpoint': {'key': 'ignoreMissingVnetServiceEndpoint', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(NWRuleSetVirtualNetworkRules, self).__init__(**kwargs) - self.subnet = kwargs.get('subnet', None) - self.ignore_missing_vnet_service_endpoint = kwargs.get('ignore_missing_vnet_service_endpoint', None) - - -class Operation(msrest.serialization.Model): - """A ServiceBus REST API operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Operation name: {provider}/{resource}/{operation}. - :vartype name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.servicebus.v2018_01_01_preview.models.OperationDisplay - """ - - _validation = { - 'name': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = None - self.display = kwargs.get('display', None) - - -class OperationDisplay(msrest.serialization.Model): - """The object that represents the operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provider: Service provider: Microsoft.ServiceBus. - :vartype provider: str - :ivar resource: Resource on which the operation is performed: Invoice, etc. - :vartype resource: str - :ivar operation: Operation type: Read, write, delete, etc. - :vartype operation: str - """ - - _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, - } - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - - -class OperationListResult(msrest.serialization.Model): - """Result of the request to list ServiceBus operations. It contains a list of operations and a URL link to get the next set of results. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of ServiceBus operations supported by the Microsoft.ServiceBus resource - provider. - :vartype value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.Operation] - :ivar next_link: URL to get the next set of operation list results if there are any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ResourceNamespacePatch(Resource): - """The Resource definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceNamespacePatch, self).__init__(**kwargs) - self.location = kwargs.get('location', None) - self.tags = kwargs.get('tags', None) - - -class PremiumMessagingRegions(ResourceNamespacePatch): - """Premium Messaging Region. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param properties: - :type properties: - ~azure.mgmt.servicebus.v2018_01_01_preview.models.PremiumMessagingRegionsProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'properties': {'key': 'properties', 'type': 'PremiumMessagingRegionsProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(PremiumMessagingRegions, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class PremiumMessagingRegionsListResult(msrest.serialization.Model): - """The response of the List PremiumMessagingRegions operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: Result of the List PremiumMessagingRegions type. - :type value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.PremiumMessagingRegions] - :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list - of PremiumMessagingRegions. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[PremiumMessagingRegions]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PremiumMessagingRegionsListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class PremiumMessagingRegionsProperties(msrest.serialization.Model): - """PremiumMessagingRegionsProperties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: Region code. - :vartype code: str - :ivar full_name: Full name of the region. - :vartype full_name: str - """ - - _validation = { - 'code': {'readonly': True}, - 'full_name': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'full_name': {'key': 'fullName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PremiumMessagingRegionsProperties, self).__init__(**kwargs) - self.code = None - self.full_name = None - - -class PrivateEndpoint(msrest.serialization.Model): - """PrivateEndpoint information. - - :param id: The ARM identifier for Private Endpoint. - :type id: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateEndpoint, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - - -class PrivateEndpointConnection(Resource): - """Properties of the PrivateEndpointConnection. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param private_endpoint: The Private Endpoint resource for this Connection. - :type private_endpoint: ~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateEndpoint - :param private_link_service_connection_state: Details about the state of the connection. - :type private_link_service_connection_state: - ~azure.mgmt.servicebus.v2018_01_01_preview.models.ConnectionState - :param provisioning_state: Provisioning state of the Private Endpoint Connection. Possible - values include: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". - :type provisioning_state: str or - ~azure.mgmt.servicebus.v2018_01_01_preview.models.EndPointProvisioningState - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'private_endpoint': {'key': 'properties.privateEndpoint', 'type': 'PrivateEndpoint'}, - 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'ConnectionState'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateEndpointConnection, self).__init__(**kwargs) - self.private_endpoint = kwargs.get('private_endpoint', None) - self.private_link_service_connection_state = kwargs.get('private_link_service_connection_state', None) - self.provisioning_state = kwargs.get('provisioning_state', None) - - -class PrivateEndpointConnectionListResult(msrest.serialization.Model): - """Result of the list of all private endpoint connections operation. - - :param value: A collection of private endpoint connection resources. - :type value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateEndpointConnection] - :param next_link: A link for the next page of private endpoint connection resources. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class PrivateLinkResource(msrest.serialization.Model): - """Information of the private link resource. - - :param id: Fully qualified identifier of the resource. - :type id: str - :param name: Name of the resource. - :type name: str - :param type: Type of the resource. - :type type: str - :param group_id: - :type group_id: str - :param required_members: Required Members. - :type required_members: list[str] - :param required_zone_names: Required Zone Names. - :type required_zone_names: list[str] - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'required_members': {'key': 'properties.requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'properties.requiredZoneNames', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateLinkResource, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.name = kwargs.get('name', None) - self.type = kwargs.get('type', None) - self.group_id = kwargs.get('group_id', None) - self.required_members = kwargs.get('required_members', None) - self.required_zone_names = kwargs.get('required_zone_names', None) - - -class PrivateLinkResourcesListResult(msrest.serialization.Model): - """Result of the List private link resources operation. - - :param value: A collection of private link resources. - :type value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateLinkResource] - :param next_link: A link for the next page of private link resources. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateLinkResourcesListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class RegenerateAccessKeyParameters(msrest.serialization.Model): - """Parameters supplied to the Regenerate Authorization Rule operation, specifies which key needs to be reset. - - All required parameters must be populated in order to send to Azure. - - :param key_type: Required. The access key to regenerate. Possible values include: "PrimaryKey", - "SecondaryKey". - :type key_type: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.KeyType - :param key: Optional, if the key value provided, is reset for KeyType value or autogenerate Key - value set for keyType. - :type key: str - """ - - _validation = { - 'key_type': {'required': True}, - } - - _attribute_map = { - 'key_type': {'key': 'keyType', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RegenerateAccessKeyParameters, self).__init__(**kwargs) - self.key_type = kwargs['key_type'] - self.key = kwargs.get('key', None) - - -class Rule(Resource): - """Description of Rule Resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param action: Represents the filter actions which are allowed for the transformation of a - message that have been matched by a filter expression. - :type action: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Action - :param filter_type: Filter type that is evaluated against a BrokeredMessage. Possible values - include: "SqlFilter", "CorrelationFilter". - :type filter_type: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.FilterType - :param sql_filter: Properties of sqlFilter. - :type sql_filter: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SqlFilter - :param correlation_filter: Properties of correlationFilter. - :type correlation_filter: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CorrelationFilter - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'action': {'key': 'properties.action', 'type': 'Action'}, - 'filter_type': {'key': 'properties.filterType', 'type': 'str'}, - 'sql_filter': {'key': 'properties.sqlFilter', 'type': 'SqlFilter'}, - 'correlation_filter': {'key': 'properties.correlationFilter', 'type': 'CorrelationFilter'}, - } - - def __init__( - self, - **kwargs - ): - super(Rule, self).__init__(**kwargs) - self.action = kwargs.get('action', None) - self.filter_type = kwargs.get('filter_type', None) - self.sql_filter = kwargs.get('sql_filter', None) - self.correlation_filter = kwargs.get('correlation_filter', None) - - -class RuleListResult(msrest.serialization.Model): - """The response of the List rule operation. - - :param value: Result of the List Rules operation. - :type value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.Rule] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list - of rules. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Rule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RuleListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class SBAuthorizationRule(Resource): - """Description of a namespace authorization rule. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param rights: The rights associated with the rule. - :type rights: list[str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessRights] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'rights': {'key': 'properties.rights', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(SBAuthorizationRule, self).__init__(**kwargs) - self.rights = kwargs.get('rights', None) - - -class SBAuthorizationRuleListResult(msrest.serialization.Model): - """The response to the List Namespace operation. - - :param value: Result of the List Authorization Rules operation. - :type value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list - of Authorization Rules. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SBAuthorizationRule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SBAuthorizationRuleListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class TrackedResource(Resource): - """The Resource definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: Required. The Geo-location where the resource lives. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(TrackedResource, self).__init__(**kwargs) - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class SBNamespace(TrackedResource): - """Description of a namespace resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: Required. The Geo-location where the resource lives. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param sku: Properties of SKU. - :type sku: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSku - :param identity: Properties of BYOK Identity description. - :type identity: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Identity - :ivar provisioning_state: Provisioning state of the namespace. - :vartype provisioning_state: str - :ivar status: Status of the namespace. - :vartype status: str - :ivar created_at: The time the namespace was created. - :vartype created_at: ~datetime.datetime - :ivar updated_at: The time the namespace was updated. - :vartype updated_at: ~datetime.datetime - :ivar service_bus_endpoint: Endpoint you can use to perform Service Bus operations. - :vartype service_bus_endpoint: str - :ivar metric_id: Identifier for Azure Insights metrics. - :vartype metric_id: str - :param zone_redundant: Enabling this property creates a Premium Service Bus Namespace in - regions supported availability zones. - :type zone_redundant: bool - :param encryption: Properties of BYOK Encryption description. - :type encryption: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Encryption - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'service_bus_endpoint': {'readonly': True}, - 'metric_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'sku', 'type': 'SBSku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'service_bus_endpoint': {'key': 'properties.serviceBusEndpoint', 'type': 'str'}, - 'metric_id': {'key': 'properties.metricId', 'type': 'str'}, - 'zone_redundant': {'key': 'properties.zoneRedundant', 'type': 'bool'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - } - - def __init__( - self, - **kwargs - ): - super(SBNamespace, self).__init__(**kwargs) - self.sku = kwargs.get('sku', None) - self.identity = kwargs.get('identity', None) - self.provisioning_state = None - self.status = None - self.created_at = None - self.updated_at = None - self.service_bus_endpoint = None - self.metric_id = None - self.zone_redundant = kwargs.get('zone_redundant', None) - self.encryption = kwargs.get('encryption', None) - - -class SBNamespaceListResult(msrest.serialization.Model): - """The response of the List Namespace operation. - - :param value: Result of the List Namespace operation. - :type value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list - of Namespaces. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SBNamespace]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SBNamespaceListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class SBNamespaceMigrate(msrest.serialization.Model): - """Namespace Migrate Object. - - All required parameters must be populated in order to send to Azure. - - :param target_namespace_type: Required. Type of namespaces. Possible values include: - "Messaging", "NotificationHub", "Mixed", "EventHub", "Relay". - :type target_namespace_type: str or - ~azure.mgmt.servicebus.v2018_01_01_preview.models.NameSpaceType - """ - - _validation = { - 'target_namespace_type': {'required': True}, - } - - _attribute_map = { - 'target_namespace_type': {'key': 'targetNamespaceType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SBNamespaceMigrate, self).__init__(**kwargs) - self.target_namespace_type = kwargs['target_namespace_type'] - - -class SBNamespaceUpdateParameters(ResourceNamespacePatch): - """Description of a namespace resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param sku: Properties of SKU. - :type sku: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSku - :param identity: Properties of BYOK Identity description. - :type identity: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Identity - :ivar provisioning_state: Provisioning state of the namespace. - :vartype provisioning_state: str - :ivar status: Status of the namespace. - :vartype status: str - :ivar created_at: The time the namespace was created. - :vartype created_at: ~datetime.datetime - :ivar updated_at: The time the namespace was updated. - :vartype updated_at: ~datetime.datetime - :ivar service_bus_endpoint: Endpoint you can use to perform Service Bus operations. - :vartype service_bus_endpoint: str - :ivar metric_id: Identifier for Azure Insights metrics. - :vartype metric_id: str - :param zone_redundant: Enabling this property creates a Premium Service Bus Namespace in - regions supported availability zones. - :type zone_redundant: bool - :param encryption: Properties of BYOK Encryption description. - :type encryption: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Encryption - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'service_bus_endpoint': {'readonly': True}, - 'metric_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'sku', 'type': 'SBSku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'service_bus_endpoint': {'key': 'properties.serviceBusEndpoint', 'type': 'str'}, - 'metric_id': {'key': 'properties.metricId', 'type': 'str'}, - 'zone_redundant': {'key': 'properties.zoneRedundant', 'type': 'bool'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - } - - def __init__( - self, - **kwargs - ): - super(SBNamespaceUpdateParameters, self).__init__(**kwargs) - self.sku = kwargs.get('sku', None) - self.identity = kwargs.get('identity', None) - self.provisioning_state = None - self.status = None - self.created_at = None - self.updated_at = None - self.service_bus_endpoint = None - self.metric_id = None - self.zone_redundant = kwargs.get('zone_redundant', None) - self.encryption = kwargs.get('encryption', None) - - -class SBQueue(Resource): - """Description of queue Resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar count_details: Message Count Details. - :vartype count_details: ~azure.mgmt.servicebus.v2018_01_01_preview.models.MessageCountDetails - :ivar created_at: The exact time the message was created. - :vartype created_at: ~datetime.datetime - :ivar updated_at: The exact time the message was 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. - :vartype accessed_at: ~datetime.datetime - :ivar size_in_bytes: The size of the queue, in bytes. - :vartype size_in_bytes: long - :ivar message_count: The number of messages in the queue. - :vartype message_count: long - :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. Default is 1024. - :type max_size_in_megabytes: int - :param requires_duplicate_detection: A value indicating if this queue requires duplicate - detection. - :type requires_duplicate_detection: bool - :param requires_session: A value that indicates whether the queue supports the concept of - sessions. - :type requires_session: bool - :param default_message_time_to_live: ISO 8601 default message timespan to live value. This is - the duration after which the message expires, starting from when the message is sent to Service - Bus. This is the default value used when TimeToLive is not set on a message itself. - :type default_message_time_to_live: ~datetime.timedelta - :param dead_lettering_on_message_expiration: A value that indicates whether this queue has dead - letter support when a message expires. - :type dead_lettering_on_message_expiration: bool - :param duplicate_detection_history_time_window: ISO 8601 timeSpan structure that defines the - duration of the duplicate detection history. The default value is 10 minutes. - :type duplicate_detection_history_time_window: ~datetime.timedelta - :param max_delivery_count: The maximum delivery count. A message is automatically deadlettered - after this number of deliveries. default value is 10. - :type max_delivery_count: int - :param status: Enumerates the possible values for the status of a messaging entity. Possible - values include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", - "Creating", "Deleting", "Renaming", "Unknown". - :type status: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.EntityStatus - :param enable_batched_operations: Value that indicates whether server-side batched operations - are enabled. - :type enable_batched_operations: bool - :param auto_delete_on_idle: ISO 8061 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 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_to: Queue/Topic name to forward the messages. - :type forward_to: str - :param forward_dead_lettered_messages_to: Queue/Topic name to forward the Dead Letter message. - :type forward_dead_lettered_messages_to: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'count_details': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'accessed_at': {'readonly': True}, - 'size_in_bytes': {'readonly': True}, - 'message_count': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'size_in_bytes': {'key': 'properties.sizeInBytes', 'type': 'long'}, - 'message_count': {'key': 'properties.messageCount', 'type': 'long'}, - 'lock_duration': {'key': 'properties.lockDuration', 'type': 'duration'}, - 'max_size_in_megabytes': {'key': 'properties.maxSizeInMegabytes', 'type': 'int'}, - 'requires_duplicate_detection': {'key': 'properties.requiresDuplicateDetection', 'type': 'bool'}, - 'requires_session': {'key': 'properties.requiresSession', 'type': 'bool'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'duration'}, - 'dead_lettering_on_message_expiration': {'key': 'properties.deadLetteringOnMessageExpiration', 'type': 'bool'}, - 'duplicate_detection_history_time_window': {'key': 'properties.duplicateDetectionHistoryTimeWindow', 'type': 'duration'}, - 'max_delivery_count': {'key': 'properties.maxDeliveryCount', 'type': 'int'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'duration'}, - 'enable_partitioning': {'key': 'properties.enablePartitioning', 'type': 'bool'}, - 'enable_express': {'key': 'properties.enableExpress', 'type': 'bool'}, - 'forward_to': {'key': 'properties.forwardTo', 'type': 'str'}, - 'forward_dead_lettered_messages_to': {'key': 'properties.forwardDeadLetteredMessagesTo', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SBQueue, self).__init__(**kwargs) - self.count_details = None - self.created_at = None - self.updated_at = None - self.accessed_at = None - self.size_in_bytes = None - self.message_count = None - 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.status = kwargs.get('status', None) - self.enable_batched_operations = kwargs.get('enable_batched_operations', None) - self.auto_delete_on_idle = kwargs.get('auto_delete_on_idle', None) - self.enable_partitioning = kwargs.get('enable_partitioning', None) - self.enable_express = kwargs.get('enable_express', None) - self.forward_to = kwargs.get('forward_to', None) - self.forward_dead_lettered_messages_to = kwargs.get('forward_dead_lettered_messages_to', None) - - -class SBQueueListResult(msrest.serialization.Model): - """The response to the List Queues operation. - - :param value: Result of the List Queues operation. - :type value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBQueue] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list - of queues. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SBQueue]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SBQueueListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class SBSku(msrest.serialization.Model): - """SKU of the namespace. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. Name of this SKU. Possible values include: "Basic", "Standard", - "Premium". - :type name: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.SkuName - :param tier: The billing tier of this particular SKU. Possible values include: "Basic", - "Standard", "Premium". - :type tier: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.SkuTier - :param capacity: The specified messaging units for the tier. For Premium tier, capacity are 1,2 - and 4. - :type capacity: int - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(SBSku, self).__init__(**kwargs) - self.name = kwargs['name'] - self.tier = kwargs.get('tier', None) - self.capacity = kwargs.get('capacity', None) - - -class SBSubscription(Resource): - """Description of subscription resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar message_count: Number of messages. - :vartype message_count: long - :ivar created_at: Exact time the message was created. - :vartype created_at: ~datetime.datetime - :ivar accessed_at: Last time there was a receive request to this subscription. - :vartype accessed_at: ~datetime.datetime - :ivar updated_at: The exact time the message was updated. - :vartype updated_at: ~datetime.datetime - :ivar count_details: Message count details. - :vartype count_details: ~azure.mgmt.servicebus.v2018_01_01_preview.models.MessageCountDetails - :param lock_duration: ISO 8061 lock duration timespan for the subscription. The default value - is 1 minute. - :type lock_duration: ~datetime.timedelta - :param requires_session: Value indicating if a subscription supports the concept of sessions. - :type requires_session: bool - :param default_message_time_to_live: ISO 8061 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_filter_evaluation_exceptions: Value that indicates whether a - subscription has dead letter support on filter evaluation exceptions. - :type dead_lettering_on_filter_evaluation_exceptions: bool - :param dead_lettering_on_message_expiration: Value that indicates whether a subscription 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: Number of maximum deliveries. - :type max_delivery_count: int - :param status: Enumerates the possible values for the status of a messaging entity. Possible - values include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", - "Creating", "Deleting", "Renaming", "Unknown". - :type status: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.EntityStatus - :param enable_batched_operations: Value that indicates whether server-side batched operations - are enabled. - :type enable_batched_operations: bool - :param auto_delete_on_idle: ISO 8061 timeSpan idle interval after which the topic is - automatically deleted. The minimum duration is 5 minutes. - :type auto_delete_on_idle: ~datetime.timedelta - :param forward_to: Queue/Topic name to forward the messages. - :type forward_to: str - :param forward_dead_lettered_messages_to: Queue/Topic name to forward the Dead Letter message. - :type forward_dead_lettered_messages_to: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'message_count': {'readonly': True}, - 'created_at': {'readonly': True}, - 'accessed_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'count_details': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'message_count': {'key': 'properties.messageCount', 'type': 'long'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'lock_duration': {'key': 'properties.lockDuration', 'type': 'duration'}, - 'requires_session': {'key': 'properties.requiresSession', 'type': 'bool'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'duration'}, - 'dead_lettering_on_filter_evaluation_exceptions': {'key': 'properties.deadLetteringOnFilterEvaluationExceptions', 'type': 'bool'}, - 'dead_lettering_on_message_expiration': {'key': 'properties.deadLetteringOnMessageExpiration', 'type': 'bool'}, - 'duplicate_detection_history_time_window': {'key': 'properties.duplicateDetectionHistoryTimeWindow', 'type': 'duration'}, - 'max_delivery_count': {'key': 'properties.maxDeliveryCount', 'type': 'int'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'duration'}, - 'forward_to': {'key': 'properties.forwardTo', 'type': 'str'}, - 'forward_dead_lettered_messages_to': {'key': 'properties.forwardDeadLetteredMessagesTo', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SBSubscription, self).__init__(**kwargs) - self.message_count = None - self.created_at = None - self.accessed_at = None - self.updated_at = None - self.count_details = None - self.lock_duration = kwargs.get('lock_duration', None) - self.requires_session = kwargs.get('requires_session', None) - self.default_message_time_to_live = kwargs.get('default_message_time_to_live', None) - self.dead_lettering_on_filter_evaluation_exceptions = kwargs.get('dead_lettering_on_filter_evaluation_exceptions', 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.status = kwargs.get('status', None) - self.enable_batched_operations = kwargs.get('enable_batched_operations', None) - self.auto_delete_on_idle = kwargs.get('auto_delete_on_idle', None) - self.forward_to = kwargs.get('forward_to', None) - self.forward_dead_lettered_messages_to = kwargs.get('forward_dead_lettered_messages_to', None) - - -class SBSubscriptionListResult(msrest.serialization.Model): - """The response to the List Subscriptions operation. - - :param value: Result of the List Subscriptions operation. - :type value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSubscription] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list - of subscriptions. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SBSubscription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SBSubscriptionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class SBTopic(Resource): - """Description of topic resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar size_in_bytes: Size of the topic, in bytes. - :vartype size_in_bytes: long - :ivar created_at: Exact time the message was created. - :vartype created_at: ~datetime.datetime - :ivar updated_at: The exact time the message was updated. - :vartype updated_at: ~datetime.datetime - :ivar accessed_at: Last time the message was sent, or a request was received, for this topic. - :vartype accessed_at: ~datetime.datetime - :ivar subscription_count: Number of subscriptions. - :vartype subscription_count: int - :ivar count_details: Message count details. - :vartype count_details: ~azure.mgmt.servicebus.v2018_01_01_preview.models.MessageCountDetails - :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: Maximum size of the topic in megabytes, which is the size of the - memory allocated for the topic. Default is 1024. - :type max_size_in_megabytes: int - :param requires_duplicate_detection: Value indicating if this topic requires duplicate - detection. - :type requires_duplicate_detection: bool - :param duplicate_detection_history_time_window: ISO8601 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 status: Enumerates the possible values for the status of a messaging entity. Possible - values include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", - "Creating", "Deleting", "Renaming", "Unknown". - :type status: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.EntityStatus - :param support_ordering: Value that indicates whether the topic supports ordering. - :type support_ordering: bool - :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: Value that indicates whether the topic to be partitioned across - multiple message brokers is enabled. - :type enable_partitioning: bool - :param enable_express: 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 - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'size_in_bytes': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'accessed_at': {'readonly': True}, - 'subscription_count': {'readonly': True}, - 'count_details': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'size_in_bytes': {'key': 'properties.sizeInBytes', 'type': 'long'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'subscription_count': {'key': 'properties.subscriptionCount', 'type': 'int'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'duration'}, - 'max_size_in_megabytes': {'key': 'properties.maxSizeInMegabytes', 'type': 'int'}, - 'requires_duplicate_detection': {'key': 'properties.requiresDuplicateDetection', 'type': 'bool'}, - 'duplicate_detection_history_time_window': {'key': 'properties.duplicateDetectionHistoryTimeWindow', 'type': 'duration'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'support_ordering': {'key': 'properties.supportOrdering', 'type': 'bool'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'duration'}, - 'enable_partitioning': {'key': 'properties.enablePartitioning', 'type': 'bool'}, - 'enable_express': {'key': 'properties.enableExpress', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(SBTopic, self).__init__(**kwargs) - self.size_in_bytes = None - self.created_at = None - self.updated_at = None - self.accessed_at = None - self.subscription_count = None - self.count_details = None - self.default_message_time_to_live = kwargs.get('default_message_time_to_live', None) - self.max_size_in_megabytes = kwargs.get('max_size_in_megabytes', None) - self.requires_duplicate_detection = kwargs.get('requires_duplicate_detection', None) - self.duplicate_detection_history_time_window = kwargs.get('duplicate_detection_history_time_window', None) - self.enable_batched_operations = kwargs.get('enable_batched_operations', None) - self.status = kwargs.get('status', None) - self.support_ordering = kwargs.get('support_ordering', None) - self.auto_delete_on_idle = kwargs.get('auto_delete_on_idle', None) - self.enable_partitioning = kwargs.get('enable_partitioning', None) - self.enable_express = kwargs.get('enable_express', None) - - -class SBTopicListResult(msrest.serialization.Model): - """The response to the List Topics operation. - - :param value: Result of the List Topics operation. - :type value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBTopic] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list - of topics. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SBTopic]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SBTopicListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class SqlFilter(msrest.serialization.Model): - """Represents a filter which is a composition of an expression and an action that is executed in the pub/sub pipeline. - - :param sql_expression: The SQL expression. e.g. MyProperty='ABC'. - :type sql_expression: str - :param compatibility_level: This property is reserved for future use. An integer value showing - the compatibility level, currently hard-coded to 20. - :type compatibility_level: int - :param requires_preprocessing: Value that indicates whether the rule action requires - preprocessing. - :type requires_preprocessing: bool - """ - - _validation = { - 'compatibility_level': {'maximum': 20, 'minimum': 20}, - } - - _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(SqlFilter, self).__init__(**kwargs) - self.sql_expression = kwargs.get('sql_expression', None) - self.compatibility_level = kwargs.get('compatibility_level', 20) - self.requires_preprocessing = kwargs.get('requires_preprocessing', True) - - -class SqlRuleAction(Action): - """Represents set of actions written in SQL language-based syntax that is performed against a ServiceBus.Messaging.BrokeredMessage. - - :param sql_expression: SQL expression. e.g. MyProperty='ABC'. - :type sql_expression: str - :param compatibility_level: This property is reserved for future use. An integer value showing - the compatibility level, currently hard-coded to 20. - :type compatibility_level: int - :param requires_preprocessing: Value that indicates whether the rule action requires - preprocessing. - :type requires_preprocessing: bool - """ - - _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(SqlRuleAction, self).__init__(**kwargs) - - -class Subnet(msrest.serialization.Model): - """Properties supplied for Subnet. - - All required parameters must be populated in order to send to Azure. - - :param id: Required. Resource ID of Virtual Network Subnet. - :type id: str - """ - - _validation = { - 'id': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Subnet, self).__init__(**kwargs) - self.id = kwargs['id'] - - -class VirtualNetworkRule(Resource): - """Single item in a List or Get VirtualNetworkRules operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param virtual_network_subnet_id: Resource ID of Virtual Network Subnet. - :type virtual_network_subnet_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'virtual_network_subnet_id': {'key': 'properties.virtualNetworkSubnetId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VirtualNetworkRule, self).__init__(**kwargs) - self.virtual_network_subnet_id = kwargs.get('virtual_network_subnet_id', None) - - -class VirtualNetworkRuleListResult(msrest.serialization.Model): - """The response from the List namespace operation. - - :param value: Result of the List VirtualNetwork Rules operation. - :type value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.VirtualNetworkRule] - :param next_link: Link to the next set of results. Not empty if Value contains an incomplete - list of VirtualNetwork Rules. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[VirtualNetworkRule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VirtualNetworkRuleListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/models/_models_py3.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/models/_models_py3.py index f3c4e3f93962..602b33eb525f 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/models/_models_py3.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/models/_models_py3.py @@ -66,6 +66,8 @@ def __init__( self, **kwargs ): + """ + """ super(AccessKeys, self).__init__(**kwargs) self.primary_connection_string = None self.secondary_connection_string = None @@ -79,14 +81,14 @@ def __init__( class Action(msrest.serialization.Model): """Represents the filter actions which are allowed for the transformation of a message that have been matched by a filter expression. - :param sql_expression: SQL expression. e.g. MyProperty='ABC'. - :type sql_expression: str - :param compatibility_level: This property is reserved for future use. An integer value showing + :ivar sql_expression: SQL expression. e.g. MyProperty='ABC'. + :vartype sql_expression: str + :ivar compatibility_level: This property is reserved for future use. An integer value showing the compatibility level, currently hard-coded to 20. - :type compatibility_level: int - :param requires_preprocessing: Value that indicates whether the rule action requires + :vartype compatibility_level: int + :ivar requires_preprocessing: Value that indicates whether the rule action requires preprocessing. - :type requires_preprocessing: bool + :vartype requires_preprocessing: bool """ _attribute_map = { @@ -103,6 +105,16 @@ def __init__( requires_preprocessing: Optional[bool] = True, **kwargs ): + """ + :keyword sql_expression: SQL expression. e.g. MyProperty='ABC'. + :paramtype sql_expression: str + :keyword compatibility_level: This property is reserved for future use. An integer value + showing the compatibility level, currently hard-coded to 20. + :paramtype compatibility_level: int + :keyword requires_preprocessing: Value that indicates whether the rule action requires + preprocessing. + :paramtype requires_preprocessing: bool + """ super(Action, self).__init__(**kwargs) self.sql_expression = sql_expression self.compatibility_level = compatibility_level @@ -138,6 +150,8 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -162,12 +176,12 @@ class ArmDisasterRecovery(Resource): ~azure.mgmt.servicebus.v2018_01_01_preview.models.ProvisioningStateDR :ivar pending_replication_operations_count: Number of entities pending to be replicated. :vartype pending_replication_operations_count: long - :param partner_namespace: ARM Id of the Primary/Secondary eventhub namespace name, which is - part of GEO DR pairing. - :type partner_namespace: str - :param alternate_name: Primary/Secondary eventhub namespace name, which is part of GEO DR + :ivar partner_namespace: ARM Id of the Primary/Secondary eventhub namespace name, which is part + of GEO DR pairing. + :vartype partner_namespace: str + :ivar alternate_name: Primary/Secondary eventhub namespace name, which is part of GEO DR pairing. - :type alternate_name: str + :vartype alternate_name: str :ivar role: role of namespace in GEO DR - possible values 'Primary' or 'PrimaryNotReplicating' or 'Secondary'. Possible values include: "Primary", "PrimaryNotReplicating", "Secondary". :vartype role: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.RoleDisasterRecovery @@ -200,6 +214,14 @@ def __init__( alternate_name: Optional[str] = None, **kwargs ): + """ + :keyword partner_namespace: ARM Id of the Primary/Secondary eventhub namespace name, which is + part of GEO DR pairing. + :paramtype partner_namespace: str + :keyword alternate_name: Primary/Secondary eventhub namespace name, which is part of GEO DR + pairing. + :paramtype alternate_name: str + """ super(ArmDisasterRecovery, self).__init__(**kwargs) self.provisioning_state = None self.pending_replication_operations_count = None @@ -213,8 +235,8 @@ class ArmDisasterRecoveryListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: List of Alias(Disaster Recovery configurations). - :type value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.ArmDisasterRecovery] + :ivar value: List of Alias(Disaster Recovery configurations). + :vartype value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.ArmDisasterRecovery] :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of Alias(Disaster Recovery configuration). :vartype next_link: str @@ -235,6 +257,10 @@ def __init__( value: Optional[List["ArmDisasterRecovery"]] = None, **kwargs ): + """ + :keyword value: List of Alias(Disaster Recovery configurations). + :paramtype value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.ArmDisasterRecovery] + """ super(ArmDisasterRecoveryListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -243,21 +269,21 @@ def __init__( class CaptureDescription(msrest.serialization.Model): """Properties to configure capture description for eventhub. - :param enabled: A value that indicates whether capture description is enabled. - :type enabled: bool - :param encoding: Enumerates the possible values for the encoding format of capture description. + :ivar enabled: A value that indicates whether capture description is enabled. + :vartype enabled: bool + :ivar encoding: Enumerates the possible values for the encoding format of capture description. Possible values include: "Avro", "AvroDeflate". - :type encoding: str or + :vartype encoding: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.EncodingCaptureDescription - :param interval_in_seconds: The time window allows you to set the frequency with which the + :ivar interval_in_seconds: The time window allows you to set the frequency with which the capture to Azure Blobs will happen, value should between 60 to 900 seconds. - :type interval_in_seconds: int - :param size_limit_in_bytes: The size window defines the amount of data built up in your Event + :vartype interval_in_seconds: int + :ivar size_limit_in_bytes: The size window defines the amount of data built up in your Event Hub before an capture operation, value should be between 10485760 and 524288000 bytes. - :type size_limit_in_bytes: int - :param destination: Properties of Destination where capture will be stored. (Storage Account, + :vartype size_limit_in_bytes: int + :ivar destination: Properties of Destination where capture will be stored. (Storage Account, Blob Names). - :type destination: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Destination + :vartype destination: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Destination """ _validation = { @@ -283,6 +309,23 @@ def __init__( destination: Optional["Destination"] = None, **kwargs ): + """ + :keyword enabled: A value that indicates whether capture description is enabled. + :paramtype enabled: bool + :keyword encoding: Enumerates the possible values for the encoding format of capture + description. Possible values include: "Avro", "AvroDeflate". + :paramtype encoding: str or + ~azure.mgmt.servicebus.v2018_01_01_preview.models.EncodingCaptureDescription + :keyword interval_in_seconds: The time window allows you to set the frequency with which the + capture to Azure Blobs will happen, value should between 60 to 900 seconds. + :paramtype interval_in_seconds: int + :keyword size_limit_in_bytes: The size window defines the amount of data built up in your Event + Hub before an capture operation, value should be between 10485760 and 524288000 bytes. + :paramtype size_limit_in_bytes: int + :keyword destination: Properties of Destination where capture will be stored. (Storage Account, + Blob Names). + :paramtype destination: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Destination + """ super(CaptureDescription, self).__init__(**kwargs) self.enabled = enabled self.encoding = encoding @@ -296,10 +339,10 @@ class CheckNameAvailability(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The Name to check the namespace name availability and The namespace name + :ivar name: Required. The Name to check the namespace name availability and The namespace name can contain only letters, numbers, and hyphens. The namespace must start with a letter, and it must end with a letter or number. - :type name: str + :vartype name: str """ _validation = { @@ -316,6 +359,12 @@ def __init__( name: str, **kwargs ): + """ + :keyword name: Required. The Name to check the namespace name availability and The namespace + name can contain only letters, numbers, and hyphens. The namespace must start with a letter, + and it must end with a letter or number. + :paramtype name: str + """ super(CheckNameAvailability, self).__init__(**kwargs) self.name = name @@ -327,13 +376,13 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): :ivar message: The detailed info regarding the reason associated with the namespace. :vartype message: str - :param name_available: Value indicating namespace is availability, true if the namespace is + :ivar name_available: Value indicating namespace is availability, true if the namespace is available; otherwise, false. - :type name_available: bool - :param reason: The reason for unavailability of a namespace. Possible values include: "None", + :vartype name_available: bool + :ivar reason: The reason for unavailability of a namespace. Possible values include: "None", "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", "TooManyNamespaceInCurrentSubscription". - :type reason: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.UnavailableReason + :vartype reason: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.UnavailableReason """ _validation = { @@ -353,6 +402,15 @@ def __init__( reason: Optional[Union[str, "UnavailableReason"]] = None, **kwargs ): + """ + :keyword name_available: Value indicating namespace is availability, true if the namespace is + available; otherwise, false. + :paramtype name_available: bool + :keyword reason: The reason for unavailability of a namespace. Possible values include: "None", + "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", + "TooManyNamespaceInCurrentSubscription". + :paramtype reason: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.UnavailableReason + """ super(CheckNameAvailabilityResult, self).__init__(**kwargs) self.message = None self.name_available = name_available @@ -362,12 +420,12 @@ def __init__( class ConnectionState(msrest.serialization.Model): """ConnectionState information. - :param status: Status of the connection. Possible values include: "Pending", "Approved", + :ivar status: Status of the connection. Possible values include: "Pending", "Approved", "Rejected", "Disconnected". - :type status: str or + :vartype status: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateLinkConnectionStatus - :param description: Description of the connection state. - :type description: str + :ivar description: Description of the connection state. + :vartype description: str """ _attribute_map = { @@ -382,6 +440,14 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword status: Status of the connection. Possible values include: "Pending", "Approved", + "Rejected", "Disconnected". + :paramtype status: str or + ~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateLinkConnectionStatus + :keyword description: Description of the connection state. + :paramtype description: str + """ super(ConnectionState, self).__init__(**kwargs) self.status = status self.description = description @@ -390,27 +456,27 @@ def __init__( class CorrelationFilter(msrest.serialization.Model): """Represents the correlation filter expression. - :param properties: dictionary object for custom filters. - :type properties: dict[str, str] - :param correlation_id: Identifier of the correlation. - :type correlation_id: str - :param message_id: Identifier of the message. - :type message_id: str - :param to: Address to send to. - :type to: str - :param reply_to: Address of the queue to reply to. - :type reply_to: str - :param label: Application specific label. - :type label: str - :param session_id: Session identifier. - :type session_id: str - :param reply_to_session_id: Session identifier to reply to. - :type reply_to_session_id: str - :param content_type: Content type of the message. - :type content_type: str - :param requires_preprocessing: Value that indicates whether the rule action requires + :ivar properties: dictionary object for custom filters. + :vartype properties: dict[str, str] + :ivar correlation_id: Identifier of the correlation. + :vartype correlation_id: str + :ivar message_id: Identifier of the message. + :vartype message_id: str + :ivar to: Address to send to. + :vartype to: str + :ivar reply_to: Address of the queue to reply to. + :vartype reply_to: str + :ivar label: Application specific label. + :vartype label: str + :ivar session_id: Session identifier. + :vartype session_id: str + :ivar reply_to_session_id: Session identifier to reply to. + :vartype reply_to_session_id: str + :ivar content_type: Content type of the message. + :vartype content_type: str + :ivar requires_preprocessing: Value that indicates whether the rule action requires preprocessing. - :type requires_preprocessing: bool + :vartype requires_preprocessing: bool """ _attribute_map = { @@ -441,6 +507,29 @@ def __init__( requires_preprocessing: Optional[bool] = True, **kwargs ): + """ + :keyword properties: dictionary object for custom filters. + :paramtype properties: dict[str, str] + :keyword correlation_id: Identifier of the correlation. + :paramtype correlation_id: str + :keyword message_id: Identifier of the message. + :paramtype message_id: str + :keyword to: Address to send to. + :paramtype to: str + :keyword reply_to: Address of the queue to reply to. + :paramtype reply_to: str + :keyword label: Application specific label. + :paramtype label: str + :keyword session_id: Session identifier. + :paramtype session_id: str + :keyword reply_to_session_id: Session identifier to reply to. + :paramtype reply_to_session_id: str + :keyword content_type: Content type of the message. + :paramtype content_type: str + :keyword requires_preprocessing: Value that indicates whether the rule action requires + preprocessing. + :paramtype requires_preprocessing: bool + """ super(CorrelationFilter, self).__init__(**kwargs) self.properties = properties self.correlation_id = correlation_id @@ -457,17 +546,17 @@ def __init__( class Destination(msrest.serialization.Model): """Capture storage details for capture description. - :param name: Name for capture destination. - :type name: str - :param storage_account_resource_id: Resource id of the storage account to be used to create the + :ivar name: Name for capture destination. + :vartype name: str + :ivar storage_account_resource_id: Resource id of the storage account to be used to create the blobs. - :type storage_account_resource_id: str - :param blob_container: Blob container Name. - :type blob_container: str - :param archive_name_format: Blob naming convention for archive, e.g. + :vartype storage_account_resource_id: str + :ivar blob_container: Blob container Name. + :vartype blob_container: str + :ivar archive_name_format: Blob naming convention for archive, e.g. {Namespace}/{EventHub}/{PartitionId}/{Year}/{Month}/{Day}/{Hour}/{Minute}/{Second}. Here all the parameters (Namespace,EventHub .. etc) are mandatory irrespective of order. - :type archive_name_format: str + :vartype archive_name_format: str """ _attribute_map = { @@ -486,6 +575,19 @@ def __init__( archive_name_format: Optional[str] = None, **kwargs ): + """ + :keyword name: Name for capture destination. + :paramtype name: str + :keyword storage_account_resource_id: Resource id of the storage account to be used to create + the blobs. + :paramtype storage_account_resource_id: str + :keyword blob_container: Blob container Name. + :paramtype blob_container: str + :keyword archive_name_format: Blob naming convention for archive, e.g. + {Namespace}/{EventHub}/{PartitionId}/{Year}/{Month}/{Day}/{Hour}/{Minute}/{Second}. Here all + the parameters (Namespace,EventHub .. etc) are mandatory irrespective of order. + :paramtype archive_name_format: str + """ super(Destination, self).__init__(**kwargs) self.name = name self.storage_account_resource_id = storage_account_resource_id @@ -496,13 +598,13 @@ def __init__( class Encryption(msrest.serialization.Model): """Properties to configure Encryption. - :param key_vault_properties: Properties of KeyVault. - :type key_vault_properties: + :ivar key_vault_properties: Properties of KeyVault. + :vartype key_vault_properties: ~azure.mgmt.servicebus.v2018_01_01_preview.models.KeyVaultProperties - :param key_source: Enumerates the possible value of keySource for Encryption. The only + :ivar key_source: Enumerates the possible value of keySource for Encryption. The only acceptable values to pass in are None and "Microsoft.KeyVault". The default value is "Microsoft.KeyVault". - :type key_source: str + :vartype key_source: str """ _attribute_map = { @@ -517,6 +619,15 @@ def __init__( key_source: Optional[str] = "Microsoft.KeyVault", **kwargs ): + """ + :keyword key_vault_properties: Properties of KeyVault. + :paramtype key_vault_properties: + ~azure.mgmt.servicebus.v2018_01_01_preview.models.KeyVaultProperties + :keyword key_source: Enumerates the possible value of keySource for Encryption. The only + acceptable values to pass in are None and "Microsoft.KeyVault". The default value is + "Microsoft.KeyVault". + :paramtype key_source: str + """ super(Encryption, self).__init__(**kwargs) self.key_vault_properties = key_vault_properties self.key_source = key_source @@ -547,6 +658,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -555,8 +668,8 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """The resource management error response. - :param error: The error object. - :type error: ~azure.mgmt.servicebus.v2018_01_01_preview.models.ErrorResponseError + :ivar error: The error object. + :vartype error: ~azure.mgmt.servicebus.v2018_01_01_preview.models.ErrorResponseError """ _attribute_map = { @@ -569,6 +682,10 @@ def __init__( error: Optional["ErrorResponseError"] = None, **kwargs ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.servicebus.v2018_01_01_preview.models.ErrorResponseError + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -611,6 +728,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponseError, self).__init__(**kwargs) self.code = None self.message = None @@ -636,18 +755,19 @@ class Eventhub(Resource): :vartype created_at: ~datetime.datetime :ivar updated_at: The exact time the message was updated. :vartype updated_at: ~datetime.datetime - :param message_retention_in_days: Number of days to retain the events for this Event Hub, value + :ivar message_retention_in_days: Number of days to retain the events for this Event Hub, value should be 1 to 7 days. - :type message_retention_in_days: long - :param partition_count: Number of partitions created for the Event Hub, allowed values are from + :vartype message_retention_in_days: long + :ivar partition_count: Number of partitions created for the Event Hub, allowed values are from 1 to 32 partitions. - :type partition_count: long - :param status: Enumerates the possible values for the status of a Event Hub. Possible values + :vartype partition_count: long + :ivar status: Enumerates the possible values for the status of a Event Hub. Possible values include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", "Deleting", "Renaming", "Unknown". - :type status: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.EntityStatus - :param capture_description: Properties of capture description. - :type capture_description: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CaptureDescription + :vartype status: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.EntityStatus + :ivar capture_description: Properties of capture description. + :vartype capture_description: + ~azure.mgmt.servicebus.v2018_01_01_preview.models.CaptureDescription """ _validation = { @@ -683,6 +803,21 @@ def __init__( capture_description: Optional["CaptureDescription"] = None, **kwargs ): + """ + :keyword message_retention_in_days: Number of days to retain the events for this Event Hub, + value should be 1 to 7 days. + :paramtype message_retention_in_days: long + :keyword partition_count: Number of partitions created for the Event Hub, allowed values are + from 1 to 32 partitions. + :paramtype partition_count: long + :keyword status: Enumerates the possible values for the status of a Event Hub. Possible values + include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", + "Deleting", "Renaming", "Unknown". + :paramtype status: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.EntityStatus + :keyword capture_description: Properties of capture description. + :paramtype capture_description: + ~azure.mgmt.servicebus.v2018_01_01_preview.models.CaptureDescription + """ super(Eventhub, self).__init__(**kwargs) self.partition_ids = None self.created_at = None @@ -698,8 +833,8 @@ class EventHubListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: Result of the List EventHubs operation. - :type value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.Eventhub] + :ivar value: Result of the List EventHubs operation. + :vartype value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.Eventhub] :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of EventHubs. :vartype next_link: str @@ -720,6 +855,10 @@ def __init__( value: Optional[List["Eventhub"]] = None, **kwargs ): + """ + :keyword value: Result of the List EventHubs operation. + :paramtype value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.Eventhub] + """ super(EventHubListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -728,9 +867,9 @@ def __init__( class FailoverProperties(msrest.serialization.Model): """Safe failover is to indicate the service should wait for pending replication to finish before switching to the secondary. - :param is_safe_failover: Safe failover is to indicate the service should wait for pending + :ivar is_safe_failover: Safe failover is to indicate the service should wait for pending replication to finish before switching to the secondary. - :type is_safe_failover: bool + :vartype is_safe_failover: bool """ _attribute_map = { @@ -743,6 +882,11 @@ def __init__( is_safe_failover: Optional[bool] = None, **kwargs ): + """ + :keyword is_safe_failover: Safe failover is to indicate the service should wait for pending + replication to finish before switching to the secondary. + :paramtype is_safe_failover: bool + """ super(FailoverProperties, self).__init__(**kwargs) self.is_safe_failover = is_safe_failover @@ -750,14 +894,14 @@ def __init__( class Identity(msrest.serialization.Model): """Properties to configure Identity for Bring your Own Keys. - :param principal_id: ObjectId from the KeyVault. - :type principal_id: str - :param tenant_id: TenantId from the KeyVault. - :type tenant_id: str - :param type: Enumerates the possible value Identity type, which currently supports only + :ivar principal_id: ObjectId from the KeyVault. + :vartype principal_id: str + :ivar tenant_id: TenantId from the KeyVault. + :vartype tenant_id: str + :ivar type: Enumerates the possible value Identity type, which currently supports only 'SystemAssigned'. The only acceptable values to pass in are None and "SystemAssigned". The default value is "SystemAssigned". - :type type: str + :vartype type: str """ _attribute_map = { @@ -774,6 +918,16 @@ def __init__( type: Optional[str] = "SystemAssigned", **kwargs ): + """ + :keyword principal_id: ObjectId from the KeyVault. + :paramtype principal_id: str + :keyword tenant_id: TenantId from the KeyVault. + :paramtype tenant_id: str + :keyword type: Enumerates the possible value Identity type, which currently supports only + 'SystemAssigned'. The only acceptable values to pass in are None and "SystemAssigned". The + default value is "SystemAssigned". + :paramtype type: str + """ super(Identity, self).__init__(**kwargs) self.principal_id = principal_id self.tenant_id = tenant_id @@ -791,12 +945,12 @@ class IpFilterRule(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param ip_mask: IP Mask. - :type ip_mask: str - :param action: The IP Filter Action. Possible values include: "Accept", "Reject". - :type action: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.IPAction - :param filter_name: IP Filter name. - :type filter_name: str + :ivar ip_mask: IP Mask. + :vartype ip_mask: str + :ivar action: The IP Filter Action. Possible values include: "Accept", "Reject". + :vartype action: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.IPAction + :ivar filter_name: IP Filter name. + :vartype filter_name: str """ _validation = { @@ -822,6 +976,14 @@ def __init__( filter_name: Optional[str] = None, **kwargs ): + """ + :keyword ip_mask: IP Mask. + :paramtype ip_mask: str + :keyword action: The IP Filter Action. Possible values include: "Accept", "Reject". + :paramtype action: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.IPAction + :keyword filter_name: IP Filter name. + :paramtype filter_name: str + """ super(IpFilterRule, self).__init__(**kwargs) self.ip_mask = ip_mask self.action = action @@ -831,11 +993,11 @@ def __init__( class IpFilterRuleListResult(msrest.serialization.Model): """The response from the List namespace operation. - :param value: Result of the List IpFilter Rules operation. - :type value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.IpFilterRule] - :param next_link: Link to the next set of results. Not empty if Value contains an incomplete + :ivar value: Result of the List IpFilter Rules operation. + :vartype value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.IpFilterRule] + :ivar next_link: Link to the next set of results. Not empty if Value contains an incomplete list of IpFilter Rules. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -850,6 +1012,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of the List IpFilter Rules operation. + :paramtype value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.IpFilterRule] + :keyword next_link: Link to the next set of results. Not empty if Value contains an incomplete + list of IpFilter Rules. + :paramtype next_link: str + """ super(IpFilterRuleListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -858,10 +1027,10 @@ def __init__( class KeyVaultProperties(msrest.serialization.Model): """Properties to configure keyVault Properties. - :param key_name: Name of the Key from KeyVault. - :type key_name: str - :param key_vault_uri: Uri of KeyVault. - :type key_vault_uri: str + :ivar key_name: Name of the Key from KeyVault. + :vartype key_name: str + :ivar key_vault_uri: Uri of KeyVault. + :vartype key_vault_uri: str """ _attribute_map = { @@ -876,6 +1045,12 @@ def __init__( key_vault_uri: Optional[str] = None, **kwargs ): + """ + :keyword key_name: Name of the Key from KeyVault. + :paramtype key_name: str + :keyword key_vault_uri: Uri of KeyVault. + :paramtype key_vault_uri: str + """ super(KeyVaultProperties, self).__init__(**kwargs) self.key_name = key_name self.key_vault_uri = key_vault_uri @@ -919,6 +1094,8 @@ def __init__( self, **kwargs ): + """ + """ super(MessageCountDetails, self).__init__(**kwargs) self.active_message_count = None self.dead_letter_message_count = None @@ -932,8 +1109,9 @@ class MigrationConfigListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: List of Migration Configs. - :type value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigProperties] + :ivar value: List of Migration Configs. + :vartype value: + list[~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigProperties] :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of migrationConfigurations. :vartype next_link: str @@ -954,6 +1132,11 @@ def __init__( value: Optional[List["MigrationConfigProperties"]] = None, **kwargs ): + """ + :keyword value: List of Migration Configs. + :paramtype value: + list[~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigProperties] + """ super(MigrationConfigListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -974,11 +1157,11 @@ class MigrationConfigProperties(Resource): :vartype provisioning_state: str :ivar pending_replication_operations_count: Number of entities pending to be replicated. :vartype pending_replication_operations_count: long - :param target_namespace: Existing premium Namespace ARM Id name which has no entities, will be + :ivar target_namespace: Existing premium Namespace ARM Id name which has no entities, will be used for migration. - :type target_namespace: str - :param post_migration_name: Name to access Standard Namespace after migration. - :type post_migration_name: str + :vartype target_namespace: str + :ivar post_migration_name: Name to access Standard Namespace after migration. + :vartype post_migration_name: str :ivar migration_state: State in which Standard to Premium Migration is, possible values : Unknown, Reverting, Completing, Initiating, Syncing, Active. :vartype migration_state: str @@ -1011,6 +1194,13 @@ def __init__( post_migration_name: Optional[str] = None, **kwargs ): + """ + :keyword target_namespace: Existing premium Namespace ARM Id name which has no entities, will + be used for migration. + :paramtype target_namespace: str + :keyword post_migration_name: Name to access Standard Namespace after migration. + :paramtype post_migration_name: str + """ super(MigrationConfigProperties, self).__init__(**kwargs) self.provisioning_state = None self.pending_replication_operations_count = None @@ -1030,14 +1220,14 @@ class NetworkRuleSet(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param default_action: Default Action for Network Rule Set. Possible values include: "Allow", + :ivar default_action: Default Action for Network Rule Set. Possible values include: "Allow", "Deny". - :type default_action: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.DefaultAction - :param virtual_network_rules: List VirtualNetwork Rules. - :type virtual_network_rules: + :vartype default_action: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.DefaultAction + :ivar virtual_network_rules: List VirtualNetwork Rules. + :vartype virtual_network_rules: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.NWRuleSetVirtualNetworkRules] - :param ip_rules: List of IpRules. - :type ip_rules: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.NWRuleSetIpRules] + :ivar ip_rules: List of IpRules. + :vartype ip_rules: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.NWRuleSetIpRules] """ _validation = { @@ -1063,6 +1253,17 @@ def __init__( ip_rules: Optional[List["NWRuleSetIpRules"]] = None, **kwargs ): + """ + :keyword default_action: Default Action for Network Rule Set. Possible values include: "Allow", + "Deny". + :paramtype default_action: str or + ~azure.mgmt.servicebus.v2018_01_01_preview.models.DefaultAction + :keyword virtual_network_rules: List VirtualNetwork Rules. + :paramtype virtual_network_rules: + list[~azure.mgmt.servicebus.v2018_01_01_preview.models.NWRuleSetVirtualNetworkRules] + :keyword ip_rules: List of IpRules. + :paramtype ip_rules: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.NWRuleSetIpRules] + """ super(NetworkRuleSet, self).__init__(**kwargs) self.default_action = default_action self.virtual_network_rules = virtual_network_rules @@ -1072,11 +1273,11 @@ def __init__( class NetworkRuleSetListResult(msrest.serialization.Model): """The response of the List NetworkRuleSet operation. - :param value: Result of the List NetworkRuleSet operation. - :type value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleSet] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list + :ivar value: Result of the List NetworkRuleSet operation. + :vartype value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleSet] + :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of NetworkRuleSet. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -1091,6 +1292,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of the List NetworkRuleSet operation. + :paramtype value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleSet] + :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete + list of NetworkRuleSet. + :paramtype next_link: str + """ super(NetworkRuleSetListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1099,10 +1307,10 @@ def __init__( class NWRuleSetIpRules(msrest.serialization.Model): """Description of NetWorkRuleSet - IpRules resource. - :param ip_mask: IP Mask. - :type ip_mask: str - :param action: The IP Filter Action. Possible values include: "Allow". Default value: "Allow". - :type action: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleIPAction + :ivar ip_mask: IP Mask. + :vartype ip_mask: str + :ivar action: The IP Filter Action. Possible values include: "Allow". Default value: "Allow". + :vartype action: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleIPAction """ _attribute_map = { @@ -1117,6 +1325,13 @@ def __init__( action: Optional[Union[str, "NetworkRuleIPAction"]] = "Allow", **kwargs ): + """ + :keyword ip_mask: IP Mask. + :paramtype ip_mask: str + :keyword action: The IP Filter Action. Possible values include: "Allow". Default value: + "Allow". + :paramtype action: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleIPAction + """ super(NWRuleSetIpRules, self).__init__(**kwargs) self.ip_mask = ip_mask self.action = action @@ -1125,11 +1340,11 @@ def __init__( class NWRuleSetVirtualNetworkRules(msrest.serialization.Model): """Description of VirtualNetworkRules - NetworkRules resource. - :param subnet: Subnet properties. - :type subnet: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Subnet - :param ignore_missing_vnet_service_endpoint: Value that indicates whether to ignore missing - VNet Service Endpoint. - :type ignore_missing_vnet_service_endpoint: bool + :ivar subnet: Subnet properties. + :vartype subnet: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Subnet + :ivar ignore_missing_vnet_service_endpoint: Value that indicates whether to ignore missing VNet + Service Endpoint. + :vartype ignore_missing_vnet_service_endpoint: bool """ _attribute_map = { @@ -1144,6 +1359,13 @@ def __init__( ignore_missing_vnet_service_endpoint: Optional[bool] = None, **kwargs ): + """ + :keyword subnet: Subnet properties. + :paramtype subnet: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Subnet + :keyword ignore_missing_vnet_service_endpoint: Value that indicates whether to ignore missing + VNet Service Endpoint. + :paramtype ignore_missing_vnet_service_endpoint: bool + """ super(NWRuleSetVirtualNetworkRules, self).__init__(**kwargs) self.subnet = subnet self.ignore_missing_vnet_service_endpoint = ignore_missing_vnet_service_endpoint @@ -1156,8 +1378,8 @@ class Operation(msrest.serialization.Model): :ivar name: Operation name: {provider}/{resource}/{operation}. :vartype name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.servicebus.v2018_01_01_preview.models.OperationDisplay + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.servicebus.v2018_01_01_preview.models.OperationDisplay """ _validation = { @@ -1175,6 +1397,10 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.servicebus.v2018_01_01_preview.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = None self.display = display @@ -1209,6 +1435,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = None self.resource = None @@ -1241,6 +1469,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -1257,10 +1487,10 @@ class ResourceNamespacePatch(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -1284,6 +1514,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(ResourceNamespacePatch, self).__init__(**kwargs) self.location = location self.tags = tags @@ -1300,12 +1536,12 @@ class PremiumMessagingRegions(ResourceNamespacePatch): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param properties: - :type properties: + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar properties: + :vartype properties: ~azure.mgmt.servicebus.v2018_01_01_preview.models.PremiumMessagingRegionsProperties """ @@ -1332,6 +1568,15 @@ def __init__( properties: Optional["PremiumMessagingRegionsProperties"] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword properties: + :paramtype properties: + ~azure.mgmt.servicebus.v2018_01_01_preview.models.PremiumMessagingRegionsProperties + """ super(PremiumMessagingRegions, self).__init__(location=location, tags=tags, **kwargs) self.properties = properties @@ -1341,8 +1586,8 @@ class PremiumMessagingRegionsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: Result of the List PremiumMessagingRegions type. - :type value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.PremiumMessagingRegions] + :ivar value: Result of the List PremiumMessagingRegions type. + :vartype value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.PremiumMessagingRegions] :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of PremiumMessagingRegions. :vartype next_link: str @@ -1363,6 +1608,11 @@ def __init__( value: Optional[List["PremiumMessagingRegions"]] = None, **kwargs ): + """ + :keyword value: Result of the List PremiumMessagingRegions type. + :paramtype value: + list[~azure.mgmt.servicebus.v2018_01_01_preview.models.PremiumMessagingRegions] + """ super(PremiumMessagingRegionsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1393,6 +1643,8 @@ def __init__( self, **kwargs ): + """ + """ super(PremiumMessagingRegionsProperties, self).__init__(**kwargs) self.code = None self.full_name = None @@ -1401,8 +1653,8 @@ def __init__( class PrivateEndpoint(msrest.serialization.Model): """PrivateEndpoint information. - :param id: The ARM identifier for Private Endpoint. - :type id: str + :ivar id: The ARM identifier for Private Endpoint. + :vartype id: str """ _attribute_map = { @@ -1415,6 +1667,10 @@ def __init__( id: Optional[str] = None, **kwargs ): + """ + :keyword id: The ARM identifier for Private Endpoint. + :paramtype id: str + """ super(PrivateEndpoint, self).__init__(**kwargs) self.id = id @@ -1430,14 +1686,14 @@ class PrivateEndpointConnection(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param private_endpoint: The Private Endpoint resource for this Connection. - :type private_endpoint: ~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateEndpoint - :param private_link_service_connection_state: Details about the state of the connection. - :type private_link_service_connection_state: + :ivar private_endpoint: The Private Endpoint resource for this Connection. + :vartype private_endpoint: ~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateEndpoint + :ivar private_link_service_connection_state: Details about the state of the connection. + :vartype private_link_service_connection_state: ~azure.mgmt.servicebus.v2018_01_01_preview.models.ConnectionState - :param provisioning_state: Provisioning state of the Private Endpoint Connection. Possible + :ivar provisioning_state: Provisioning state of the Private Endpoint Connection. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". - :type provisioning_state: str or + :vartype provisioning_state: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.EndPointProvisioningState """ @@ -1464,6 +1720,17 @@ def __init__( provisioning_state: Optional[Union[str, "EndPointProvisioningState"]] = None, **kwargs ): + """ + :keyword private_endpoint: The Private Endpoint resource for this Connection. + :paramtype private_endpoint: ~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateEndpoint + :keyword private_link_service_connection_state: Details about the state of the connection. + :paramtype private_link_service_connection_state: + ~azure.mgmt.servicebus.v2018_01_01_preview.models.ConnectionState + :keyword provisioning_state: Provisioning state of the Private Endpoint Connection. Possible + values include: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". + :paramtype provisioning_state: str or + ~azure.mgmt.servicebus.v2018_01_01_preview.models.EndPointProvisioningState + """ super(PrivateEndpointConnection, self).__init__(**kwargs) self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state @@ -1473,10 +1740,11 @@ def __init__( class PrivateEndpointConnectionListResult(msrest.serialization.Model): """Result of the list of all private endpoint connections operation. - :param value: A collection of private endpoint connection resources. - :type value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateEndpointConnection] - :param next_link: A link for the next page of private endpoint connection resources. - :type next_link: str + :ivar value: A collection of private endpoint connection resources. + :vartype value: + list[~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateEndpointConnection] + :ivar next_link: A link for the next page of private endpoint connection resources. + :vartype next_link: str """ _attribute_map = { @@ -1491,6 +1759,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: A collection of private endpoint connection resources. + :paramtype value: + list[~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateEndpointConnection] + :keyword next_link: A link for the next page of private endpoint connection resources. + :paramtype next_link: str + """ super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1499,18 +1774,18 @@ def __init__( class PrivateLinkResource(msrest.serialization.Model): """Information of the private link resource. - :param id: Fully qualified identifier of the resource. - :type id: str - :param name: Name of the resource. - :type name: str - :param type: Type of the resource. - :type type: str - :param group_id: - :type group_id: str - :param required_members: Required Members. - :type required_members: list[str] - :param required_zone_names: Required Zone Names. - :type required_zone_names: list[str] + :ivar id: Fully qualified identifier of the resource. + :vartype id: str + :ivar name: Name of the resource. + :vartype name: str + :ivar type: Type of the resource. + :vartype type: str + :ivar group_id: + :vartype group_id: str + :ivar required_members: Required Members. + :vartype required_members: list[str] + :ivar required_zone_names: Required Zone Names. + :vartype required_zone_names: list[str] """ _attribute_map = { @@ -1533,6 +1808,20 @@ def __init__( required_zone_names: Optional[List[str]] = None, **kwargs ): + """ + :keyword id: Fully qualified identifier of the resource. + :paramtype id: str + :keyword name: Name of the resource. + :paramtype name: str + :keyword type: Type of the resource. + :paramtype type: str + :keyword group_id: + :paramtype group_id: str + :keyword required_members: Required Members. + :paramtype required_members: list[str] + :keyword required_zone_names: Required Zone Names. + :paramtype required_zone_names: list[str] + """ super(PrivateLinkResource, self).__init__(**kwargs) self.id = id self.name = name @@ -1545,10 +1834,10 @@ def __init__( class PrivateLinkResourcesListResult(msrest.serialization.Model): """Result of the List private link resources operation. - :param value: A collection of private link resources. - :type value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateLinkResource] - :param next_link: A link for the next page of private link resources. - :type next_link: str + :ivar value: A collection of private link resources. + :vartype value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateLinkResource] + :ivar next_link: A link for the next page of private link resources. + :vartype next_link: str """ _attribute_map = { @@ -1563,6 +1852,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: A collection of private link resources. + :paramtype value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateLinkResource] + :keyword next_link: A link for the next page of private link resources. + :paramtype next_link: str + """ super(PrivateLinkResourcesListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1573,12 +1868,12 @@ class RegenerateAccessKeyParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param key_type: Required. The access key to regenerate. Possible values include: "PrimaryKey", + :ivar key_type: Required. The access key to regenerate. Possible values include: "PrimaryKey", "SecondaryKey". - :type key_type: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.KeyType - :param key: Optional, if the key value provided, is reset for KeyType value or autogenerate Key + :vartype key_type: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.KeyType + :ivar key: Optional, if the key value provided, is reset for KeyType value or autogenerate Key value set for keyType. - :type key: str + :vartype key: str """ _validation = { @@ -1597,6 +1892,14 @@ def __init__( key: Optional[str] = None, **kwargs ): + """ + :keyword key_type: Required. The access key to regenerate. Possible values include: + "PrimaryKey", "SecondaryKey". + :paramtype key_type: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.KeyType + :keyword key: Optional, if the key value provided, is reset for KeyType value or autogenerate + Key value set for keyType. + :paramtype key: str + """ super(RegenerateAccessKeyParameters, self).__init__(**kwargs) self.key_type = key_type self.key = key @@ -1613,16 +1916,17 @@ class Rule(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param action: Represents the filter actions which are allowed for the transformation of a + :ivar action: Represents the filter actions which are allowed for the transformation of a message that have been matched by a filter expression. - :type action: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Action - :param filter_type: Filter type that is evaluated against a BrokeredMessage. Possible values + :vartype action: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Action + :ivar filter_type: Filter type that is evaluated against a BrokeredMessage. Possible values include: "SqlFilter", "CorrelationFilter". - :type filter_type: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.FilterType - :param sql_filter: Properties of sqlFilter. - :type sql_filter: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SqlFilter - :param correlation_filter: Properties of correlationFilter. - :type correlation_filter: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CorrelationFilter + :vartype filter_type: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.FilterType + :ivar sql_filter: Properties of sqlFilter. + :vartype sql_filter: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SqlFilter + :ivar correlation_filter: Properties of correlationFilter. + :vartype correlation_filter: + ~azure.mgmt.servicebus.v2018_01_01_preview.models.CorrelationFilter """ _validation = { @@ -1650,6 +1954,19 @@ def __init__( correlation_filter: Optional["CorrelationFilter"] = None, **kwargs ): + """ + :keyword action: Represents the filter actions which are allowed for the transformation of a + message that have been matched by a filter expression. + :paramtype action: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Action + :keyword filter_type: Filter type that is evaluated against a BrokeredMessage. Possible values + include: "SqlFilter", "CorrelationFilter". + :paramtype filter_type: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.FilterType + :keyword sql_filter: Properties of sqlFilter. + :paramtype sql_filter: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SqlFilter + :keyword correlation_filter: Properties of correlationFilter. + :paramtype correlation_filter: + ~azure.mgmt.servicebus.v2018_01_01_preview.models.CorrelationFilter + """ super(Rule, self).__init__(**kwargs) self.action = action self.filter_type = filter_type @@ -1660,11 +1977,11 @@ def __init__( class RuleListResult(msrest.serialization.Model): """The response of the List rule operation. - :param value: Result of the List Rules operation. - :type value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.Rule] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list + :ivar value: Result of the List Rules operation. + :vartype value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.Rule] + :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of rules. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -1679,6 +1996,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of the List Rules operation. + :paramtype value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.Rule] + :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete + list of rules. + :paramtype next_link: str + """ super(RuleListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1695,8 +2019,8 @@ class SBAuthorizationRule(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param rights: The rights associated with the rule. - :type rights: list[str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessRights] + :ivar rights: The rights associated with the rule. + :vartype rights: list[str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessRights] """ _validation = { @@ -1718,6 +2042,10 @@ def __init__( rights: Optional[List[Union[str, "AccessRights"]]] = None, **kwargs ): + """ + :keyword rights: The rights associated with the rule. + :paramtype rights: list[str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessRights] + """ super(SBAuthorizationRule, self).__init__(**kwargs) self.rights = rights @@ -1725,11 +2053,11 @@ def __init__( class SBAuthorizationRuleListResult(msrest.serialization.Model): """The response to the List Namespace operation. - :param value: Result of the List Authorization Rules operation. - :type value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list + :ivar value: Result of the List Authorization Rules operation. + :vartype value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule] + :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of Authorization Rules. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -1744,6 +2072,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of the List Authorization Rules operation. + :paramtype value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule] + :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete + list of Authorization Rules. + :paramtype next_link: str + """ super(SBAuthorizationRuleListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1762,10 +2097,10 @@ class TrackedResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Required. The Geo-location where the resource lives. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Required. The Geo-location where the resource lives. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -1790,6 +2125,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. The Geo-location where the resource lives. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(TrackedResource, self).__init__(**kwargs) self.location = location self.tags = tags @@ -1808,14 +2149,14 @@ class SBNamespace(TrackedResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Required. The Geo-location where the resource lives. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param sku: Properties of SKU. - :type sku: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSku - :param identity: Properties of BYOK Identity description. - :type identity: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Identity + :ivar location: Required. The Geo-location where the resource lives. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar sku: Properties of SKU. + :vartype sku: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSku + :ivar identity: Properties of BYOK Identity description. + :vartype identity: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Identity :ivar provisioning_state: Provisioning state of the namespace. :vartype provisioning_state: str :ivar status: Status of the namespace. @@ -1828,11 +2169,11 @@ class SBNamespace(TrackedResource): :vartype service_bus_endpoint: str :ivar metric_id: Identifier for Azure Insights metrics. :vartype metric_id: str - :param zone_redundant: Enabling this property creates a Premium Service Bus Namespace in - regions supported availability zones. - :type zone_redundant: bool - :param encryption: Properties of BYOK Encryption description. - :type encryption: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Encryption + :ivar zone_redundant: Enabling this property creates a Premium Service Bus Namespace in regions + supported availability zones. + :vartype zone_redundant: bool + :ivar encryption: Properties of BYOK Encryption description. + :vartype encryption: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Encryption """ _validation = { @@ -1877,6 +2218,21 @@ def __init__( encryption: Optional["Encryption"] = None, **kwargs ): + """ + :keyword location: Required. The Geo-location where the resource lives. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword sku: Properties of SKU. + :paramtype sku: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSku + :keyword identity: Properties of BYOK Identity description. + :paramtype identity: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Identity + :keyword zone_redundant: Enabling this property creates a Premium Service Bus Namespace in + regions supported availability zones. + :paramtype zone_redundant: bool + :keyword encryption: Properties of BYOK Encryption description. + :paramtype encryption: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Encryption + """ super(SBNamespace, self).__init__(location=location, tags=tags, **kwargs) self.sku = sku self.identity = identity @@ -1893,11 +2249,11 @@ def __init__( class SBNamespaceListResult(msrest.serialization.Model): """The response of the List Namespace operation. - :param value: Result of the List Namespace operation. - :type value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list + :ivar value: Result of the List Namespace operation. + :vartype value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace] + :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of Namespaces. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -1912,6 +2268,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of the List Namespace operation. + :paramtype value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace] + :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete + list of Namespaces. + :paramtype next_link: str + """ super(SBNamespaceListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1922,9 +2285,9 @@ class SBNamespaceMigrate(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param target_namespace_type: Required. Type of namespaces. Possible values include: + :ivar target_namespace_type: Required. Type of namespaces. Possible values include: "Messaging", "NotificationHub", "Mixed", "EventHub", "Relay". - :type target_namespace_type: str or + :vartype target_namespace_type: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.NameSpaceType """ @@ -1942,6 +2305,12 @@ def __init__( target_namespace_type: Union[str, "NameSpaceType"], **kwargs ): + """ + :keyword target_namespace_type: Required. Type of namespaces. Possible values include: + "Messaging", "NotificationHub", "Mixed", "EventHub", "Relay". + :paramtype target_namespace_type: str or + ~azure.mgmt.servicebus.v2018_01_01_preview.models.NameSpaceType + """ super(SBNamespaceMigrate, self).__init__(**kwargs) self.target_namespace_type = target_namespace_type @@ -1957,14 +2326,14 @@ class SBNamespaceUpdateParameters(ResourceNamespacePatch): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param sku: Properties of SKU. - :type sku: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSku - :param identity: Properties of BYOK Identity description. - :type identity: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar sku: Properties of SKU. + :vartype sku: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSku + :ivar identity: Properties of BYOK Identity description. + :vartype identity: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Identity :ivar provisioning_state: Provisioning state of the namespace. :vartype provisioning_state: str :ivar status: Status of the namespace. @@ -1977,11 +2346,11 @@ class SBNamespaceUpdateParameters(ResourceNamespacePatch): :vartype service_bus_endpoint: str :ivar metric_id: Identifier for Azure Insights metrics. :vartype metric_id: str - :param zone_redundant: Enabling this property creates a Premium Service Bus Namespace in - regions supported availability zones. - :type zone_redundant: bool - :param encryption: Properties of BYOK Encryption description. - :type encryption: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Encryption + :ivar zone_redundant: Enabling this property creates a Premium Service Bus Namespace in regions + supported availability zones. + :vartype zone_redundant: bool + :ivar encryption: Properties of BYOK Encryption description. + :vartype encryption: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Encryption """ _validation = { @@ -2025,6 +2394,21 @@ def __init__( encryption: Optional["Encryption"] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword sku: Properties of SKU. + :paramtype sku: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSku + :keyword identity: Properties of BYOK Identity description. + :paramtype identity: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Identity + :keyword zone_redundant: Enabling this property creates a Premium Service Bus Namespace in + regions supported availability zones. + :paramtype zone_redundant: bool + :keyword encryption: Properties of BYOK Encryption description. + :paramtype encryption: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Encryption + """ super(SBNamespaceUpdateParameters, self).__init__(location=location, tags=tags, **kwargs) self.sku = sku self.identity = identity @@ -2062,52 +2446,52 @@ class SBQueue(Resource): :vartype size_in_bytes: long :ivar message_count: The number of messages in the queue. :vartype message_count: long - :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. Default is 1024. - :type max_size_in_megabytes: int - :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 status: Enumerates the possible values for the status of a messaging entity. Possible + :vartype max_delivery_count: int + :ivar status: Enumerates the possible values for the status of a messaging entity. Possible values include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", "Deleting", "Renaming", "Unknown". - :type status: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.EntityStatus - :param enable_batched_operations: Value that indicates whether server-side batched operations + :vartype status: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.EntityStatus + :ivar enable_batched_operations: Value that indicates whether server-side batched operations are enabled. - :type enable_batched_operations: bool - :param auto_delete_on_idle: ISO 8061 timeSpan idle interval after which the queue is + :vartype enable_batched_operations: bool + :ivar auto_delete_on_idle: ISO 8061 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 enable_express: A value that indicates whether Express Entities are enabled. An express + :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 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_to: Queue/Topic name to forward the messages. - :type forward_to: str - :param forward_dead_lettered_messages_to: Queue/Topic name to forward the Dead Letter message. - :type forward_dead_lettered_messages_to: str + :vartype enable_express: bool + :ivar forward_to: Queue/Topic name to forward the messages. + :vartype forward_to: str + :ivar forward_dead_lettered_messages_to: Queue/Topic name to forward the Dead Letter message. + :vartype forward_dead_lettered_messages_to: str """ _validation = { @@ -2169,6 +2553,55 @@ def __init__( forward_dead_lettered_messages_to: Optional[str] = None, **kwargs ): + """ + :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. Default is 1024. + :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 status: Enumerates the possible values for the status of a messaging entity. Possible + values include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", + "Creating", "Deleting", "Renaming", "Unknown". + :paramtype status: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.EntityStatus + :keyword enable_batched_operations: Value that indicates whether server-side batched operations + are enabled. + :paramtype enable_batched_operations: bool + :keyword auto_delete_on_idle: ISO 8061 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 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_to: Queue/Topic name to forward the messages. + :paramtype forward_to: str + :keyword forward_dead_lettered_messages_to: Queue/Topic name to forward the Dead Letter + message. + :paramtype forward_dead_lettered_messages_to: str + """ super(SBQueue, self).__init__(**kwargs) self.count_details = None self.created_at = None @@ -2196,11 +2629,11 @@ def __init__( class SBQueueListResult(msrest.serialization.Model): """The response to the List Queues operation. - :param value: Result of the List Queues operation. - :type value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBQueue] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list + :ivar value: Result of the List Queues operation. + :vartype value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBQueue] + :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of queues. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -2215,6 +2648,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of the List Queues operation. + :paramtype value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBQueue] + :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete + list of queues. + :paramtype next_link: str + """ super(SBQueueListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -2225,15 +2665,15 @@ class SBSku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. Name of this SKU. Possible values include: "Basic", "Standard", + :ivar name: Required. Name of this SKU. Possible values include: "Basic", "Standard", "Premium". - :type name: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.SkuName - :param tier: The billing tier of this particular SKU. Possible values include: "Basic", + :vartype name: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.SkuName + :ivar tier: The billing tier of this particular SKU. Possible values include: "Basic", "Standard", "Premium". - :type tier: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.SkuTier - :param capacity: The specified messaging units for the tier. For Premium tier, capacity are 1,2 + :vartype tier: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.SkuTier + :ivar capacity: The specified messaging units for the tier. For Premium tier, capacity are 1,2 and 4. - :type capacity: int + :vartype capacity: int """ _validation = { @@ -2254,6 +2694,17 @@ def __init__( capacity: Optional[int] = None, **kwargs ): + """ + :keyword name: Required. Name of this SKU. Possible values include: "Basic", "Standard", + "Premium". + :paramtype name: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.SkuName + :keyword tier: The billing tier of this particular SKU. Possible values include: "Basic", + "Standard", "Premium". + :paramtype tier: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.SkuTier + :keyword capacity: The specified messaging units for the tier. For Premium tier, capacity are + 1,2 and 4. + :paramtype capacity: int + """ super(SBSku, self).__init__(**kwargs) self.name = name self.tier = tier @@ -2281,40 +2732,40 @@ class SBSubscription(Resource): :vartype updated_at: ~datetime.datetime :ivar count_details: Message count details. :vartype count_details: ~azure.mgmt.servicebus.v2018_01_01_preview.models.MessageCountDetails - :param lock_duration: ISO 8061 lock duration timespan for the subscription. The default value - is 1 minute. - :type lock_duration: ~datetime.timedelta - :param requires_session: Value indicating if a subscription supports the concept of sessions. - :type requires_session: bool - :param default_message_time_to_live: ISO 8061 Default message timespan to live value. This is + :ivar lock_duration: ISO 8061 lock duration timespan for the subscription. The default value is + 1 minute. + :vartype lock_duration: ~datetime.timedelta + :ivar requires_session: Value indicating if a subscription supports the concept of sessions. + :vartype requires_session: bool + :ivar default_message_time_to_live: ISO 8061 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_filter_evaluation_exceptions: Value that indicates whether a + :vartype default_message_time_to_live: ~datetime.timedelta + :ivar dead_lettering_on_filter_evaluation_exceptions: Value that indicates whether a subscription has dead letter support on filter evaluation exceptions. - :type dead_lettering_on_filter_evaluation_exceptions: bool - :param dead_lettering_on_message_expiration: Value that indicates whether a subscription has + :vartype dead_lettering_on_filter_evaluation_exceptions: bool + :ivar dead_lettering_on_message_expiration: Value that indicates whether a subscription 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: Number of maximum deliveries. - :type max_delivery_count: int - :param status: Enumerates the possible values for the status of a messaging entity. Possible + :vartype duplicate_detection_history_time_window: ~datetime.timedelta + :ivar max_delivery_count: Number of maximum deliveries. + :vartype max_delivery_count: int + :ivar status: Enumerates the possible values for the status of a messaging entity. Possible values include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", "Deleting", "Renaming", "Unknown". - :type status: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.EntityStatus - :param enable_batched_operations: Value that indicates whether server-side batched operations + :vartype status: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.EntityStatus + :ivar enable_batched_operations: Value that indicates whether server-side batched operations are enabled. - :type enable_batched_operations: bool - :param auto_delete_on_idle: ISO 8061 timeSpan idle interval after which the topic is + :vartype enable_batched_operations: bool + :ivar auto_delete_on_idle: ISO 8061 timeSpan idle interval after which the topic is automatically deleted. The minimum duration is 5 minutes. - :type auto_delete_on_idle: ~datetime.timedelta - :param forward_to: Queue/Topic name to forward the messages. - :type forward_to: str - :param forward_dead_lettered_messages_to: Queue/Topic name to forward the Dead Letter message. - :type forward_dead_lettered_messages_to: str + :vartype auto_delete_on_idle: ~datetime.timedelta + :ivar forward_to: Queue/Topic name to forward the messages. + :vartype forward_to: str + :ivar forward_dead_lettered_messages_to: Queue/Topic name to forward the Dead Letter message. + :vartype forward_dead_lettered_messages_to: str """ _validation = { @@ -2368,6 +2819,43 @@ def __init__( forward_dead_lettered_messages_to: Optional[str] = None, **kwargs ): + """ + :keyword lock_duration: ISO 8061 lock duration timespan for the subscription. The default value + is 1 minute. + :paramtype lock_duration: ~datetime.timedelta + :keyword requires_session: Value indicating if a subscription supports the concept of sessions. + :paramtype requires_session: bool + :keyword default_message_time_to_live: ISO 8061 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_filter_evaluation_exceptions: Value that indicates whether a + subscription has dead letter support on filter evaluation exceptions. + :paramtype dead_lettering_on_filter_evaluation_exceptions: bool + :keyword dead_lettering_on_message_expiration: Value that indicates whether a subscription 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: Number of maximum deliveries. + :paramtype max_delivery_count: int + :keyword status: Enumerates the possible values for the status of a messaging entity. Possible + values include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", + "Creating", "Deleting", "Renaming", "Unknown". + :paramtype status: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.EntityStatus + :keyword enable_batched_operations: Value that indicates whether server-side batched operations + are enabled. + :paramtype enable_batched_operations: bool + :keyword auto_delete_on_idle: ISO 8061 timeSpan idle interval after which the topic is + automatically deleted. The minimum duration is 5 minutes. + :paramtype auto_delete_on_idle: ~datetime.timedelta + :keyword forward_to: Queue/Topic name to forward the messages. + :paramtype forward_to: str + :keyword forward_dead_lettered_messages_to: Queue/Topic name to forward the Dead Letter + message. + :paramtype forward_dead_lettered_messages_to: str + """ super(SBSubscription, self).__init__(**kwargs) self.message_count = None self.created_at = None @@ -2391,11 +2879,11 @@ def __init__( class SBSubscriptionListResult(msrest.serialization.Model): """The response to the List Subscriptions operation. - :param value: Result of the List Subscriptions operation. - :type value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSubscription] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list + :ivar value: Result of the List Subscriptions operation. + :vartype value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSubscription] + :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of subscriptions. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -2410,6 +2898,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of the List Subscriptions operation. + :paramtype value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSubscription] + :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete + list of subscriptions. + :paramtype next_link: str + """ super(SBSubscriptionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -2438,37 +2933,37 @@ class SBTopic(Resource): :vartype subscription_count: int :ivar count_details: Message count details. :vartype count_details: ~azure.mgmt.servicebus.v2018_01_01_preview.models.MessageCountDetails - :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: Maximum size of the topic in megabytes, which is the size of the + :vartype default_message_time_to_live: ~datetime.timedelta + :ivar max_size_in_megabytes: Maximum size of the topic in megabytes, which is the size of the memory allocated for the topic. Default is 1024. - :type max_size_in_megabytes: int - :param requires_duplicate_detection: Value indicating if this topic requires duplicate + :vartype max_size_in_megabytes: int + :ivar requires_duplicate_detection: Value indicating if this topic requires duplicate detection. - :type requires_duplicate_detection: bool - :param duplicate_detection_history_time_window: ISO8601 timespan structure that defines the + :vartype requires_duplicate_detection: bool + :ivar duplicate_detection_history_time_window: ISO8601 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 status: Enumerates the possible values for the status of a messaging entity. Possible + :vartype enable_batched_operations: bool + :ivar status: Enumerates the possible values for the status of a messaging entity. Possible values include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", "Deleting", "Renaming", "Unknown". - :type status: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.EntityStatus - :param support_ordering: Value that indicates whether the topic supports ordering. - :type support_ordering: bool - :param auto_delete_on_idle: ISO 8601 timespan idle interval after which the topic is + :vartype status: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.EntityStatus + :ivar support_ordering: Value that indicates whether the topic supports ordering. + :vartype support_ordering: bool + :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: Value that indicates whether the topic to be partitioned across + :vartype auto_delete_on_idle: ~datetime.timedelta + :ivar enable_partitioning: Value that indicates whether the topic to be partitioned across multiple message brokers is enabled. - :type enable_partitioning: bool - :param enable_express: Value that indicates whether Express Entities are enabled. An express + :vartype enable_partitioning: bool + :ivar enable_express: 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 + :vartype enable_express: bool """ _validation = { @@ -2520,6 +3015,39 @@ def __init__( enable_express: Optional[bool] = None, **kwargs ): + """ + :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: Maximum size of the topic in megabytes, which is the size of + the memory allocated for the topic. Default is 1024. + :paramtype max_size_in_megabytes: int + :keyword requires_duplicate_detection: Value indicating if this topic requires duplicate + detection. + :paramtype requires_duplicate_detection: bool + :keyword duplicate_detection_history_time_window: ISO8601 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 status: Enumerates the possible values for the status of a messaging entity. Possible + values include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", + "Creating", "Deleting", "Renaming", "Unknown". + :paramtype status: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.EntityStatus + :keyword support_ordering: Value that indicates whether the topic supports ordering. + :paramtype support_ordering: bool + :keyword auto_delete_on_idle: ISO 8601 timespan idle interval after which the topic is + automatically deleted. The minimum duration is 5 minutes. + :paramtype auto_delete_on_idle: ~datetime.timedelta + :keyword enable_partitioning: Value that indicates whether the topic to be partitioned across + multiple message brokers is enabled. + :paramtype enable_partitioning: bool + :keyword enable_express: 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 + """ super(SBTopic, self).__init__(**kwargs) self.size_in_bytes = None self.created_at = None @@ -2542,11 +3070,11 @@ def __init__( class SBTopicListResult(msrest.serialization.Model): """The response to the List Topics operation. - :param value: Result of the List Topics operation. - :type value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBTopic] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list + :ivar value: Result of the List Topics operation. + :vartype value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBTopic] + :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of topics. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -2561,6 +3089,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of the List Topics operation. + :paramtype value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBTopic] + :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete + list of topics. + :paramtype next_link: str + """ super(SBTopicListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -2569,14 +3104,14 @@ def __init__( class SqlFilter(msrest.serialization.Model): """Represents a filter which is a composition of an expression and an action that is executed in the pub/sub pipeline. - :param sql_expression: The SQL expression. e.g. MyProperty='ABC'. - :type sql_expression: str - :param compatibility_level: This property is reserved for future use. An integer value showing + :ivar sql_expression: The SQL expression. e.g. MyProperty='ABC'. + :vartype sql_expression: str + :ivar compatibility_level: This property is reserved for future use. An integer value showing the compatibility level, currently hard-coded to 20. - :type compatibility_level: int - :param requires_preprocessing: Value that indicates whether the rule action requires + :vartype compatibility_level: int + :ivar requires_preprocessing: Value that indicates whether the rule action requires preprocessing. - :type requires_preprocessing: bool + :vartype requires_preprocessing: bool """ _validation = { @@ -2597,6 +3132,16 @@ def __init__( requires_preprocessing: Optional[bool] = True, **kwargs ): + """ + :keyword sql_expression: The SQL expression. e.g. MyProperty='ABC'. + :paramtype sql_expression: str + :keyword compatibility_level: This property is reserved for future use. An integer value + showing the compatibility level, currently hard-coded to 20. + :paramtype compatibility_level: int + :keyword requires_preprocessing: Value that indicates whether the rule action requires + preprocessing. + :paramtype requires_preprocessing: bool + """ super(SqlFilter, self).__init__(**kwargs) self.sql_expression = sql_expression self.compatibility_level = compatibility_level @@ -2606,14 +3151,14 @@ def __init__( class SqlRuleAction(Action): """Represents set of actions written in SQL language-based syntax that is performed against a ServiceBus.Messaging.BrokeredMessage. - :param sql_expression: SQL expression. e.g. MyProperty='ABC'. - :type sql_expression: str - :param compatibility_level: This property is reserved for future use. An integer value showing + :ivar sql_expression: SQL expression. e.g. MyProperty='ABC'. + :vartype sql_expression: str + :ivar compatibility_level: This property is reserved for future use. An integer value showing the compatibility level, currently hard-coded to 20. - :type compatibility_level: int - :param requires_preprocessing: Value that indicates whether the rule action requires + :vartype compatibility_level: int + :ivar requires_preprocessing: Value that indicates whether the rule action requires preprocessing. - :type requires_preprocessing: bool + :vartype requires_preprocessing: bool """ _attribute_map = { @@ -2630,6 +3175,16 @@ def __init__( requires_preprocessing: Optional[bool] = True, **kwargs ): + """ + :keyword sql_expression: SQL expression. e.g. MyProperty='ABC'. + :paramtype sql_expression: str + :keyword compatibility_level: This property is reserved for future use. An integer value + showing the compatibility level, currently hard-coded to 20. + :paramtype compatibility_level: int + :keyword requires_preprocessing: Value that indicates whether the rule action requires + preprocessing. + :paramtype requires_preprocessing: bool + """ super(SqlRuleAction, self).__init__(sql_expression=sql_expression, compatibility_level=compatibility_level, requires_preprocessing=requires_preprocessing, **kwargs) @@ -2638,8 +3193,8 @@ class Subnet(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Required. Resource ID of Virtual Network Subnet. - :type id: str + :ivar id: Required. Resource ID of Virtual Network Subnet. + :vartype id: str """ _validation = { @@ -2656,6 +3211,10 @@ def __init__( id: str, **kwargs ): + """ + :keyword id: Required. Resource ID of Virtual Network Subnet. + :paramtype id: str + """ super(Subnet, self).__init__(**kwargs) self.id = id @@ -2671,8 +3230,8 @@ class VirtualNetworkRule(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param virtual_network_subnet_id: Resource ID of Virtual Network Subnet. - :type virtual_network_subnet_id: str + :ivar virtual_network_subnet_id: Resource ID of Virtual Network Subnet. + :vartype virtual_network_subnet_id: str """ _validation = { @@ -2694,6 +3253,10 @@ def __init__( virtual_network_subnet_id: Optional[str] = None, **kwargs ): + """ + :keyword virtual_network_subnet_id: Resource ID of Virtual Network Subnet. + :paramtype virtual_network_subnet_id: str + """ super(VirtualNetworkRule, self).__init__(**kwargs) self.virtual_network_subnet_id = virtual_network_subnet_id @@ -2701,11 +3264,11 @@ def __init__( class VirtualNetworkRuleListResult(msrest.serialization.Model): """The response from the List namespace operation. - :param value: Result of the List VirtualNetwork Rules operation. - :type value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.VirtualNetworkRule] - :param next_link: Link to the next set of results. Not empty if Value contains an incomplete + :ivar value: Result of the List VirtualNetwork Rules operation. + :vartype value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.VirtualNetworkRule] + :ivar next_link: Link to the next set of results. Not empty if Value contains an incomplete list of VirtualNetwork Rules. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -2720,6 +3283,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of the List VirtualNetwork Rules operation. + :paramtype value: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.VirtualNetworkRule] + :keyword next_link: Link to the next set of results. Not empty if Value contains an incomplete + list of VirtualNetwork Rules. + :paramtype next_link: str + """ super(VirtualNetworkRuleListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/models/_service_bus_management_client_enums.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/models/_service_bus_management_client_enums.py index efc83ca107d3..732c21924f2c 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/models/_service_bus_management_client_enums.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/models/_service_bus_management_client_enums.py @@ -6,47 +6,32 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AccessRights(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MANAGE = "Manage" SEND = "Send" LISTEN = "Listen" -class DefaultAction(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DefaultAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Default Action for Network Rule Set """ ALLOW = "Allow" DENY = "Deny" -class EncodingCaptureDescription(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class EncodingCaptureDescription(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Enumerates the possible values for the encoding format of capture description. """ AVRO = "Avro" AVRO_DEFLATE = "AvroDeflate" -class EndPointProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class EndPointProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Provisioning state of the Private Endpoint Connection. """ @@ -57,7 +42,7 @@ class EndPointProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, En CANCELED = "Canceled" FAILED = "Failed" -class EntityStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class EntityStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Entity status. """ @@ -71,32 +56,32 @@ class EntityStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): RENAMING = "Renaming" UNKNOWN = "Unknown" -class FilterType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class FilterType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Rule filter types """ SQL_FILTER = "SqlFilter" CORRELATION_FILTER = "CorrelationFilter" -class IPAction(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IPAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The IP Filter Action """ ACCEPT = "Accept" REJECT = "Reject" -class KeyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class KeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The access key to regenerate. """ PRIMARY_KEY = "PrimaryKey" SECONDARY_KEY = "SecondaryKey" -class MigrationConfigurationName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class MigrationConfigurationName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): _DEFAULT = "$default" -class NameSpaceType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class NameSpaceType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of namespaces """ @@ -106,13 +91,13 @@ class NameSpaceType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): EVENT_HUB = "EventHub" RELAY = "Relay" -class NetworkRuleIPAction(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class NetworkRuleIPAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The IP Filter Action """ ALLOW = "Allow" -class PrivateLinkConnectionStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PrivateLinkConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Status of the connection. """ @@ -121,7 +106,7 @@ class PrivateLinkConnectionStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, REJECTED = "Rejected" DISCONNECTED = "Disconnected" -class ProvisioningStateDR(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningStateDR(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Provisioning state of the Alias(Disaster Recovery configuration) - possible values 'Accepted' or 'Succeeded' or 'Failed' """ @@ -130,7 +115,7 @@ class ProvisioningStateDR(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" FAILED = "Failed" -class RoleDisasterRecovery(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RoleDisasterRecovery(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """role of namespace in GEO DR - possible values 'Primary' or 'PrimaryNotReplicating' or 'Secondary' """ @@ -139,7 +124,7 @@ class RoleDisasterRecovery(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PRIMARY_NOT_REPLICATING = "PrimaryNotReplicating" SECONDARY = "Secondary" -class SkuName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Name of this SKU. """ @@ -147,7 +132,7 @@ class SkuName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): STANDARD = "Standard" PREMIUM = "Premium" -class SkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The billing tier of this particular SKU. """ @@ -155,7 +140,7 @@ class SkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): STANDARD = "Standard" PREMIUM = "Premium" -class UnavailableReason(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class UnavailableReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Specifies the reason for the unavailability of the service. """ diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_disaster_recovery_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_disaster_recovery_configs_operations.py index 8c9a32491e71..4058f9f2a837 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_disaster_recovery_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_disaster_recovery_configs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,429 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_check_name_availability_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + namespace_name: str, + alias: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + namespace_name: str, + alias: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + namespace_name: str, + alias: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_break_pairing_request( + resource_group_name: str, + namespace_name: str, + alias: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_fail_over_request( + resource_group_name: str, + namespace_name: str, + alias: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_authorization_rules_request( + resource_group_name: str, + namespace_name: str, + alias: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + alias: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_keys_request( + resource_group_name: str, + namespace_name: str, + alias: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class DisasterRecoveryConfigsOperations(object): """DisasterRecoveryConfigsOperations operations. @@ -45,14 +452,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def check_name_availability( self, - resource_group_name, # type: str - namespace_name, # type: str - parameters, # type: "_models.CheckNameAvailability" - **kwargs # type: Any - ): - # type: (...) -> "_models.CheckNameAvailabilityResult" + resource_group_name: str, + namespace_name: str, + parameters: "_models.CheckNameAvailability", + **kwargs: Any + ) -> "_models.CheckNameAvailabilityResult": """Check the give namespace name availability. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -71,38 +478,34 @@ def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CheckNameAvailability') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'CheckNameAvailability') + + request = build_check_name_availability_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) @@ -111,15 +514,17 @@ def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability"} # type: ignore + + + @distributed_trace def list( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ArmDisasterRecoveryListResult"] + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> Iterable["_models.ArmDisasterRecoveryListResult"]: """Gets all Alias(Disaster Recovery configurations). :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -127,45 +532,48 @@ def list( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ArmDisasterRecoveryListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.ArmDisasterRecoveryListResult] + :return: An iterator like instance of either ArmDisasterRecoveryListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.ArmDisasterRecoveryListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ArmDisasterRecoveryListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ArmDisasterRecoveryListResult', pipeline_response) + deserialized = self._deserialize("ArmDisasterRecoveryListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -174,30 +582,35 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs"} # type: ignore + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - namespace_name, # type: str - alias, # type: str - parameters, # type: "_models.ArmDisasterRecovery" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ArmDisasterRecovery"] + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: "_models.ArmDisasterRecovery", + **kwargs: Any + ) -> Optional["_models.ArmDisasterRecovery"]: """Creates or updates a new Alias(Disaster Recovery configuration). :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -218,39 +631,35 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ArmDisasterRecovery') - 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) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ArmDisasterRecovery') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -261,16 +670,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}'} # type: ignore - def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - alias, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + alias: str, + **kwargs: Any + ) -> None: """Deletes an Alias(Disaster Recovery configuration). :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -289,49 +700,47 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - namespace_name, # type: str - alias, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ArmDisasterRecovery" + resource_group_name: str, + namespace_name: str, + alias: str, + **kwargs: Any + ) -> "_models.ArmDisasterRecovery": """Retrieves Alias(Disaster Recovery configuration) for primary or secondary namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -350,34 +759,31 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) @@ -386,16 +792,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}'} # type: ignore - def break_pairing( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore + + + @distributed_trace + def break_pairing( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - alias, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + alias: str, + **kwargs: Any + ) -> None: """This operation disables the Disaster Recovery and stops replicating changes from primary to secondary namespaces. @@ -415,50 +823,48 @@ def break_pairing( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.break_pairing.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_break_pairing_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.break_pairing.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - break_pairing.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing'} # type: ignore + break_pairing.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing"} # type: ignore + - def fail_over( + @distributed_trace + def fail_over( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - alias, # type: str - parameters=None, # type: Optional["_models.FailoverProperties"] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional["_models.FailoverProperties"] = None, + **kwargs: Any + ) -> None: """Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -468,6 +874,7 @@ def fail_over( :param alias: The Disaster Recovery configuration name. :type alias: str :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Default value is None. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.FailoverProperties :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) @@ -479,57 +886,54 @@ def fail_over( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.fail_over.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if parameters is not None: - body_content = self._serialize.body(parameters, 'FailoverProperties') + _json = self._serialize.body(parameters, 'FailoverProperties') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + _json = None + + request = build_fail_over_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.fail_over.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - fail_over.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover'} # type: ignore + fail_over.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover"} # type: ignore + + @distributed_trace def list_authorization_rules( self, - resource_group_name, # type: str - namespace_name, # type: str - alias, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SBAuthorizationRuleListResult"] + resource_group_name: str, + namespace_name: str, + alias: str, + **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRuleListResult"]: """Gets the authorization rules for a namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -539,46 +943,50 @@ def list_authorization_rules( :param alias: The Disaster Recovery configuration name. :type alias: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRuleListResult] + :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SBAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -587,30 +995,35 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules"} # type: ignore + @distributed_trace def get_authorization_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - alias, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SBAuthorizationRule" + resource_group_name: str, + namespace_name: str, + alias: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.SBAuthorizationRule": """Gets an authorization rule for a namespace by rule name. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -631,35 +1044,32 @@ def get_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -668,17 +1078,19 @@ def get_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}'} # type: ignore + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace def list_keys( self, - resource_group_name, # type: str - namespace_name, # type: str - alias, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessKeys" + resource_group_name: str, + namespace_name: str, + alias: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.AccessKeys": """Gets the primary and secondary connection strings for the namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -699,35 +1111,32 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -736,4 +1145,6 @@ def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys'} # type: ignore + + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_event_hubs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_event_hubs_operations.py index 02f7e9039ab8..9360833ba85c 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_event_hubs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_event_hubs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,60 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_namespace_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/eventhubs") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class EventHubsOperations(object): """EventHubsOperations operations. @@ -45,13 +83,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_namespace( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.EventHubListResult"] + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> Iterable["_models.EventHubListResult"]: """Gets all the Event Hubs in a service bus Namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -60,44 +98,46 @@ def list_by_namespace( :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EventHubListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.EventHubListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.EventHubListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_namespace.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_namespace.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('EventHubListResult', pipeline_response) + deserialized = self._deserialize("EventHubListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,17 +146,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_namespace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/eventhubs'} # type: ignore + list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/eventhubs"} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_migration_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_migration_configs_operations.py index c8ab4f1f1b0e..215bff0ba292 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_migration_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_migration_configs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,25 +6,261 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_and_start_migration_request_initial( + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_complete_migration_request( + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_revert_request( + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class MigrationConfigsOperations(object): """MigrationConfigsOperations operations. @@ -47,13 +284,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MigrationConfigListResult"] + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> Iterable["_models.MigrationConfigListResult"]: """Gets all migrationConfigurations. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -61,45 +298,48 @@ def list( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MigrationConfigListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigListResult] + :return: An iterator like instance of either MigrationConfigListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.MigrationConfigListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('MigrationConfigListResult', pipeline_response) + deserialized = self._deserialize("MigrationConfigListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -108,69 +348,68 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations"} # type: ignore def _create_and_start_migration_initial( self, - resource_group_name, # type: str - namespace_name, # type: str - config_name, # type: Union[str, "_models.MigrationConfigurationName"] - parameters, # type: "_models.MigrationConfigProperties" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.MigrationConfigProperties"] + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + parameters: "_models.MigrationConfigProperties", + **kwargs: Any + ) -> Optional["_models.MigrationConfigProperties"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.MigrationConfigProperties"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_and_start_migration_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'MigrationConfigProperties') - 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) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'MigrationConfigProperties') + + request = build_create_and_start_migration_request_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_and_start_migration_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -180,17 +419,19 @@ def _create_and_start_migration_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_and_start_migration_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}'} # type: ignore + _create_and_start_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + + + @distributed_trace def begin_create_and_start_migration( self, - resource_group_name, # type: str - namespace_name, # type: str - config_name, # type: Union[str, "_models.MigrationConfigurationName"] - parameters, # type: "_models.MigrationConfigProperties" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.MigrationConfigProperties"] + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + parameters: "_models.MigrationConfigProperties", + **kwargs: Any + ) -> LROPoller["_models.MigrationConfigProperties"]: """Creates Migration configuration and starts migration of entities from Standard to Premium namespace. @@ -199,19 +440,26 @@ def begin_create_and_start_migration( :param namespace_name: The namespace name. :type namespace_name: str :param config_name: The configuration name. Should always be "$default". - :type config_name: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigurationName + :type config_name: str or + ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigurationName :param parameters: Parameters required to create Migration Configuration. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigProperties :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either MigrationConfigProperties or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigProperties] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MigrationConfigProperties or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigProperties] + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.MigrationConfigProperties"] lro_delay = kwargs.pop( @@ -225,28 +473,22 @@ def begin_create_and_start_migration( namespace_name=namespace_name, config_name=config_name, parameters=parameters, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -256,18 +498,18 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_and_start_migration.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def delete( + begin_create_and_start_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - config_name, # type: Union[str, "_models.MigrationConfigurationName"] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + **kwargs: Any + ) -> None: """Deletes a MigrationConfiguration. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -275,7 +517,8 @@ def delete( :param namespace_name: The namespace name. :type namespace_name: str :param config_name: The configuration name. Should always be "$default". - :type config_name: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigurationName + :type config_name: str or + ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigurationName :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -286,49 +529,47 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - namespace_name, # type: str - config_name, # type: Union[str, "_models.MigrationConfigurationName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.MigrationConfigProperties" + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + **kwargs: Any + ) -> "_models.MigrationConfigProperties": """Retrieves Migration Config. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -336,7 +577,8 @@ def get( :param namespace_name: The namespace name. :type namespace_name: str :param config_name: The configuration name. Should always be "$default". - :type config_name: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigurationName + :type config_name: str or + ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigurationName :keyword callable cls: A custom type or function that will be passed the direct response :return: MigrationConfigProperties, or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigProperties @@ -347,34 +589,31 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) @@ -383,16 +622,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}'} # type: ignore - def complete_migration( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + + + @distributed_trace + def complete_migration( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - config_name, # type: Union[str, "_models.MigrationConfigurationName"] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + **kwargs: Any + ) -> None: """This operation Completes Migration of entities by pointing the connection strings to Premium namespace and any entities created after the operation will be under Premium Namespace. CompleteMigration operation will fail when entity migration is in-progress. @@ -402,7 +643,8 @@ def complete_migration( :param namespace_name: The namespace name. :type namespace_name: str :param config_name: The configuration name. Should always be "$default". - :type config_name: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigurationName + :type config_name: str or + ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigurationName :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -413,49 +655,47 @@ def complete_migration( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.complete_migration.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_complete_migration_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.complete_migration.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - complete_migration.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade'} # type: ignore + complete_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade"} # type: ignore - def revert( + + @distributed_trace + def revert( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - config_name, # type: Union[str, "_models.MigrationConfigurationName"] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + **kwargs: Any + ) -> None: """This operation reverts Migration. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -463,7 +703,8 @@ def revert( :param namespace_name: The namespace name. :type namespace_name: str :param config_name: The configuration name. Should always be "$default". - :type config_name: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigurationName + :type config_name: str or + ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigurationName :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -474,37 +715,35 @@ def revert( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.revert.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_revert_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.revert.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - revert.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert'} # type: ignore + revert.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_namespaces_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_namespaces_operations.py index ac5186a54fd3..ddecba7a59d5 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_namespaces_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_namespaces_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,27 +6,1013 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class NamespacesOperations(object): +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_ip_filter_rules_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_ip_filter_rule_request( + resource_group_name: str, + namespace_name: str, + ip_filter_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules/{ipFilterRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "ipFilterRuleName": _SERIALIZER.url("ip_filter_rule_name", ip_filter_rule_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_ip_filter_rule_request( + resource_group_name: str, + namespace_name: str, + ip_filter_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules/{ipFilterRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "ipFilterRuleName": _SERIALIZER.url("ip_filter_rule_name", ip_filter_rule_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_ip_filter_rule_request( + resource_group_name: str, + namespace_name: str, + ip_filter_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules/{ipFilterRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "ipFilterRuleName": _SERIALIZER.url("ip_filter_rule_name", ip_filter_rule_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_virtual_network_rules_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_virtual_network_rule_request( + resource_group_name: str, + namespace_name: str, + virtual_network_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules/{virtualNetworkRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "virtualNetworkRuleName": _SERIALIZER.url("virtual_network_rule_name", virtual_network_rule_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_virtual_network_rule_request( + resource_group_name: str, + namespace_name: str, + virtual_network_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules/{virtualNetworkRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "virtualNetworkRuleName": _SERIALIZER.url("virtual_network_rule_name", virtual_network_rule_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_virtual_network_rule_request( + resource_group_name: str, + namespace_name: str, + virtual_network_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules/{virtualNetworkRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "virtualNetworkRuleName": _SERIALIZER.url("virtual_network_rule_name", virtual_network_rule_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_authorization_rules_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_keys_request( + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_regenerate_keys_request( + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_check_name_availability_request( + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_create_or_update_network_rule_set_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_network_rule_set_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_network_rule_sets_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_migrate_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrate") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + +class NamespacesOperations(object): # pylint: disable=too-many-public-methods """NamespacesOperations operations. You should not instantiate this class directly. Instead, you should create a Client instance that @@ -47,13 +1034,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_ip_filter_rules( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IpFilterRuleListResult"] + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> Iterable["_models.IpFilterRuleListResult"]: """Gets a list of IP Filter rules for a Namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -61,45 +1048,48 @@ def list_ip_filter_rules( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IpFilterRuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.IpFilterRuleListResult] + :return: An iterator like instance of either IpFilterRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.IpFilterRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.IpFilterRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_ip_filter_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_ip_filter_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_ip_filter_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_ip_filter_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IpFilterRuleListResult', pipeline_response) + deserialized = self._deserialize("IpFilterRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -108,30 +1098,35 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_ip_filter_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules'} # type: ignore + list_ip_filter_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules"} # type: ignore + @distributed_trace def create_or_update_ip_filter_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - ip_filter_rule_name, # type: str - parameters, # type: "_models.IpFilterRule" - **kwargs # type: Any - ): - # type: (...) -> "_models.IpFilterRule" + resource_group_name: str, + namespace_name: str, + ip_filter_rule_name: str, + parameters: "_models.IpFilterRule", + **kwargs: Any + ) -> "_models.IpFilterRule": """Creates or updates an IpFilterRule for a Namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -152,39 +1147,35 @@ def create_or_update_ip_filter_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_ip_filter_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'ipFilterRuleName': self._serialize.url("ip_filter_rule_name", ip_filter_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'IpFilterRule') - 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) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'IpFilterRule') + + request = build_create_or_update_ip_filter_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + ip_filter_rule_name=ip_filter_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_ip_filter_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IpFilterRule', pipeline_response) @@ -193,16 +1184,18 @@ def create_or_update_ip_filter_rule( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_ip_filter_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules/{ipFilterRuleName}'} # type: ignore - def delete_ip_filter_rule( + create_or_update_ip_filter_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules/{ipFilterRuleName}"} # type: ignore + + + @distributed_trace + def delete_ip_filter_rule( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - ip_filter_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + ip_filter_rule_name: str, + **kwargs: Any + ) -> None: """Deletes an IpFilterRule for a Namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -221,49 +1214,47 @@ def delete_ip_filter_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_ip_filter_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'ipFilterRuleName': self._serialize.url("ip_filter_rule_name", ip_filter_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_ip_filter_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + ip_filter_rule_name=ip_filter_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_ip_filter_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete_ip_filter_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules/{ipFilterRuleName}'} # type: ignore + delete_ip_filter_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules/{ipFilterRuleName}"} # type: ignore + + @distributed_trace def get_ip_filter_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - ip_filter_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.IpFilterRule" + resource_group_name: str, + namespace_name: str, + ip_filter_rule_name: str, + **kwargs: Any + ) -> "_models.IpFilterRule": """Gets an IpFilterRule for a Namespace by rule name. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -282,34 +1273,31 @@ def get_ip_filter_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_ip_filter_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'ipFilterRuleName': self._serialize.url("ip_filter_rule_name", ip_filter_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_ip_filter_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + ip_filter_rule_name=ip_filter_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_ip_filter_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IpFilterRule', pipeline_response) @@ -318,53 +1306,56 @@ def get_ip_filter_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_ip_filter_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules/{ipFilterRuleName}'} # type: ignore + get_ip_filter_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/ipfilterrules/{ipFilterRuleName}"} # type: ignore + + + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SBNamespaceListResult"] + **kwargs: Any + ) -> Iterable["_models.SBNamespaceListResult"]: """Gets all the available namespaces within the subscription, irrespective of the resource groups. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBNamespaceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespaceListResult] + :return: An iterator like instance of either SBNamespaceListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespaceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBNamespaceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SBNamespaceListResult', pipeline_response) + deserialized = self._deserialize("SBNamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -373,70 +1364,77 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces"} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SBNamespaceListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.SBNamespaceListResult"]: """Gets the available namespaces within a resource group. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBNamespaceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespaceListResult] + :return: An iterator like instance of either SBNamespaceListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespaceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBNamespaceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SBNamespaceListResult', pipeline_response) + deserialized = self._deserialize("SBNamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -445,67 +1443,66 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces"} # type: ignore def _create_or_update_initial( self, - resource_group_name, # type: str - namespace_name, # type: str - parameters, # type: "_models.SBNamespace" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.SBNamespace"] + resource_group_name: str, + namespace_name: str, + parameters: "_models.SBNamespace", + **kwargs: Any + ) -> Optional["_models.SBNamespace"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.SBNamespace"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBNamespace') - 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) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBNamespace') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -518,16 +1515,18 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - namespace_name, # type: str - parameters, # type: "_models.SBNamespace" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.SBNamespace"] + resource_group_name: str, + namespace_name: str, + parameters: "_models.SBNamespace", + **kwargs: Any + ) -> LROPoller["_models.SBNamespace"]: """Creates or updates a service namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. @@ -539,14 +1538,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either SBNamespace or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either SBNamespace or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace] + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.SBNamespace"] lro_delay = kwargs.pop( @@ -559,27 +1564,22 @@ def begin_create_or_update( resource_group_name=resource_group_name, namespace_name=namespace_name, parameters=parameters, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('SBNamespace', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -589,63 +1589,59 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def _delete_initial( + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + - def begin_delete( + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes an existing namespace. This operation also removes all associated resources under the namespace. @@ -655,14 +1651,17 @@ def begin_delete( :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( @@ -674,24 +1673,18 @@ def begin_delete( raw_result = self._delete_initial( resource_group_name=resource_group_name, namespace_name=namespace_name, + api_version=api_version, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -701,17 +1694,17 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SBNamespace" + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> "_models.SBNamespace": """Gets a description for the specified namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -728,33 +1721,30 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBNamespace', pipeline_response) @@ -763,16 +1753,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + + @distributed_trace def update( self, - resource_group_name, # type: str - namespace_name, # type: str - parameters, # type: "_models.SBNamespaceUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.SBNamespace"] + resource_group_name: str, + namespace_name: str, + parameters: "_models.SBNamespaceUpdateParameters", + **kwargs: Any + ) -> Optional["_models.SBNamespace"]: """Updates a service namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. @@ -792,38 +1784,34 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -837,15 +1825,17 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + + @distributed_trace def list_virtual_network_rules( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.VirtualNetworkRuleListResult"] + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> Iterable["_models.VirtualNetworkRuleListResult"]: """Gets a list of VirtualNetwork rules for a Namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -853,45 +1843,48 @@ def list_virtual_network_rules( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VirtualNetworkRuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.VirtualNetworkRuleListResult] + :return: An iterator like instance of either VirtualNetworkRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.VirtualNetworkRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetworkRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_virtual_network_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_virtual_network_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_virtual_network_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_virtual_network_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('VirtualNetworkRuleListResult', pipeline_response) + deserialized = self._deserialize("VirtualNetworkRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -900,30 +1893,35 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_virtual_network_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules'} # type: ignore + list_virtual_network_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules"} # type: ignore + @distributed_trace def create_or_update_virtual_network_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - virtual_network_rule_name, # type: str - parameters, # type: "_models.VirtualNetworkRule" - **kwargs # type: Any - ): - # type: (...) -> "_models.VirtualNetworkRule" + resource_group_name: str, + namespace_name: str, + virtual_network_rule_name: str, + parameters: "_models.VirtualNetworkRule", + **kwargs: Any + ) -> "_models.VirtualNetworkRule": """Creates or updates an VirtualNetworkRule for a Namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -944,39 +1942,35 @@ def create_or_update_virtual_network_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_virtual_network_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'virtualNetworkRuleName': self._serialize.url("virtual_network_rule_name", virtual_network_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'VirtualNetworkRule') - 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) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'VirtualNetworkRule') + + request = build_create_or_update_virtual_network_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + virtual_network_rule_name=virtual_network_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_virtual_network_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('VirtualNetworkRule', pipeline_response) @@ -985,16 +1979,18 @@ def create_or_update_virtual_network_rule( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_virtual_network_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules/{virtualNetworkRuleName}'} # type: ignore - def delete_virtual_network_rule( + create_or_update_virtual_network_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules/{virtualNetworkRuleName}"} # type: ignore + + + @distributed_trace + def delete_virtual_network_rule( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - virtual_network_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + virtual_network_rule_name: str, + **kwargs: Any + ) -> None: """Deletes an VirtualNetworkRule for a Namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -1013,49 +2009,47 @@ def delete_virtual_network_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_virtual_network_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'virtualNetworkRuleName': self._serialize.url("virtual_network_rule_name", virtual_network_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_virtual_network_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + virtual_network_rule_name=virtual_network_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_virtual_network_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete_virtual_network_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules/{virtualNetworkRuleName}'} # type: ignore + delete_virtual_network_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules/{virtualNetworkRuleName}"} # type: ignore + + @distributed_trace def get_virtual_network_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - virtual_network_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.VirtualNetworkRule" + resource_group_name: str, + namespace_name: str, + virtual_network_rule_name: str, + **kwargs: Any + ) -> "_models.VirtualNetworkRule": """Gets an VirtualNetworkRule for a Namespace by rule name. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -1074,34 +2068,31 @@ def get_virtual_network_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_virtual_network_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'virtualNetworkRuleName': self._serialize.url("virtual_network_rule_name", virtual_network_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_virtual_network_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + virtual_network_rule_name=virtual_network_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_virtual_network_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('VirtualNetworkRule', pipeline_response) @@ -1110,15 +2101,17 @@ def get_virtual_network_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_virtual_network_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules/{virtualNetworkRuleName}'} # type: ignore + get_virtual_network_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/virtualnetworkrules/{virtualNetworkRuleName}"} # type: ignore + + + @distributed_trace def list_authorization_rules( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SBAuthorizationRuleListResult"] + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRuleListResult"]: """Gets the authorization rules for a namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -1126,45 +2119,48 @@ def list_authorization_rules( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRuleListResult] + :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SBAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1173,30 +2169,35 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules"} # type: ignore + @distributed_trace def create_or_update_authorization_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - authorization_rule_name, # type: str - parameters, # type: "_models.SBAuthorizationRule" - **kwargs # type: Any - ): - # type: (...) -> "_models.SBAuthorizationRule" + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: "_models.SBAuthorizationRule", + **kwargs: Any + ) -> "_models.SBAuthorizationRule": """Creates or updates an authorization rule for a namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -1217,39 +2218,35 @@ def create_or_update_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBAuthorizationRule') - 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) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBAuthorizationRule') + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -1258,16 +2255,18 @@ def create_or_update_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}'} # type: ignore - def delete_authorization_rule( + create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace + def delete_authorization_rule( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> None: """Deletes a namespace authorization rule. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -1286,49 +2285,47 @@ def delete_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}'} # type: ignore + delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore + + @distributed_trace def get_authorization_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SBAuthorizationRule" + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.SBAuthorizationRule": """Gets an authorization rule for a namespace by rule name. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -1347,34 +2344,31 @@ def get_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -1383,16 +2377,18 @@ def get_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}'} # type: ignore + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace def list_keys( self, - resource_group_name, # type: str - namespace_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessKeys" + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.AccessKeys": """Gets the primary and secondary connection strings for the namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -1411,34 +2407,31 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -1447,17 +2440,19 @@ def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore + + + @distributed_trace def regenerate_keys( self, - resource_group_name, # type: str - namespace_name, # type: str - authorization_rule_name, # type: str - parameters, # type: "_models.RegenerateAccessKeyParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessKeys" + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: "_models.RegenerateAccessKeyParameters", + **kwargs: Any + ) -> "_models.AccessKeys": """Regenerates the primary or secondary connection strings for the namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -1467,7 +2462,8 @@ def regenerate_keys( :param authorization_rule_name: The authorization rule name. :type authorization_rule_name: str :param parameters: Parameters supplied to regenerate the authorization rule. - :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.RegenerateAccessKeyParameters + :type parameters: + ~azure.mgmt.servicebus.v2018_01_01_preview.models.RegenerateAccessKeyParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessKeys, or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys @@ -1478,39 +2474,35 @@ def regenerate_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -1519,14 +2511,16 @@ def regenerate_keys( return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys'} # type: ignore + regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + + + @distributed_trace def check_name_availability( self, - parameters, # type: "_models.CheckNameAvailability" - **kwargs # type: Any - ): - # type: (...) -> "_models.CheckNameAvailabilityResult" + parameters: "_models.CheckNameAvailability", + **kwargs: Any + ) -> "_models.CheckNameAvailabilityResult": """Check the give namespace name availability. :param parameters: Parameters to check availability of the given namespace name. @@ -1541,36 +2535,32 @@ def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CheckNameAvailability') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'CheckNameAvailability') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) @@ -1579,16 +2569,18 @@ def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability"} # type: ignore + + + @distributed_trace def create_or_update_network_rule_set( self, - resource_group_name, # type: str - namespace_name, # type: str - parameters, # type: "_models.NetworkRuleSet" - **kwargs # type: Any - ): - # type: (...) -> "_models.NetworkRuleSet" + resource_group_name: str, + namespace_name: str, + parameters: "_models.NetworkRuleSet", + **kwargs: Any + ) -> "_models.NetworkRuleSet": """Create or update NetworkRuleSet for a Namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -1607,38 +2599,34 @@ def create_or_update_network_rule_set( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_network_rule_set.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'NetworkRuleSet') - 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) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'NetworkRuleSet') + + request = build_create_or_update_network_rule_set_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_network_rule_set.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('NetworkRuleSet', pipeline_response) @@ -1647,15 +2635,17 @@ def create_or_update_network_rule_set( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_network_rule_set.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default'} # type: ignore + create_or_update_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore + + + @distributed_trace def get_network_rule_set( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.NetworkRuleSet" + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> "_models.NetworkRuleSet": """Gets NetworkRuleSet for a Namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -1672,33 +2662,30 @@ def get_network_rule_set( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_network_rule_set.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_network_rule_set_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_network_rule_set.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('NetworkRuleSet', pipeline_response) @@ -1707,15 +2694,17 @@ def get_network_rule_set( return cls(pipeline_response, deserialized, {}) return deserialized - get_network_rule_set.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default'} # type: ignore + get_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore + + + @distributed_trace def list_network_rule_sets( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.NetworkRuleSetListResult"] + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> Iterable["_models.NetworkRuleSetListResult"]: """Gets list of NetworkRuleSet for a Namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -1723,45 +2712,48 @@ def list_network_rule_sets( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NetworkRuleSetListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleSetListResult] + :return: An iterator like instance of either NetworkRuleSetListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkRuleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_network_rule_sets.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_network_rule_sets_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_network_rule_sets.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_network_rule_sets_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('NetworkRuleSetListResult', pipeline_response) + deserialized = self._deserialize("NetworkRuleSetListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1770,29 +2762,34 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_network_rule_sets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets'} # type: ignore + list_network_rule_sets.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets"} # type: ignore - def migrate( + @distributed_trace + def migrate( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - parameters, # type: "_models.SBNamespaceMigrate" - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + parameters: "_models.SBNamespaceMigrate", + **kwargs: Any + ) -> None: """This operation Migrate the given namespace to provided name type. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -1811,41 +2808,38 @@ def migrate( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.migrate.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBNamespaceMigrate') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBNamespaceMigrate') + + request = build_migrate_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.migrate.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - migrate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrate'} # type: ignore + migrate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrate"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_operations.py index a2299672a426..0089454fa3d5 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,50 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.ServiceBus/operations") + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,47 +73,49 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationListResult"] + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: """Lists all of the available ServiceBus REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.OperationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -94,17 +124,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.ServiceBus/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.ServiceBus/operations"} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_premium_messaging_regions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_premium_messaging_regions_operations.py index a0234237b68b..fdaaff0b2793 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_premium_messaging_regions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_premium_messaging_regions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,56 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/premiumMessagingRegions") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class PremiumMessagingRegionsOperations(object): """PremiumMessagingRegionsOperations operations. @@ -45,51 +79,52 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PremiumMessagingRegionsListResult"] + **kwargs: Any + ) -> Iterable["_models.PremiumMessagingRegionsListResult"]: """Gets the available premium messaging regions for servicebus. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PremiumMessagingRegionsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.PremiumMessagingRegionsListResult] + :return: An iterator like instance of either PremiumMessagingRegionsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.PremiumMessagingRegionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.PremiumMessagingRegionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PremiumMessagingRegionsListResult', pipeline_response) + deserialized = self._deserialize("PremiumMessagingRegionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,17 +133,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/premiumMessagingRegions'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/premiumMessagingRegions"} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_private_endpoint_connections_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_private_endpoint_connections_operations.py index 4caf5090bd21..7d9c7ed16227 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_private_endpoint_connections_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_private_endpoint_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,25 +6,185 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + private_endpoint_connection_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class PrivateEndpointConnectionsOperations(object): """PrivateEndpointConnectionsOperations operations. @@ -47,13 +208,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PrivateEndpointConnectionListResult"] + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnectionListResult"]: """Gets the available PrivateEndpointConnections within a namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -61,45 +222,48 @@ def list( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateEndpointConnectionListResult] + :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PrivateEndpointConnectionListResult', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -108,30 +272,35 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections"} # type: ignore + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - namespace_name, # type: str - private_endpoint_connection_name, # type: str - parameters, # type: "_models.PrivateEndpointConnection" - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateEndpointConnection" + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: "_models.PrivateEndpointConnection", + **kwargs: Any + ) -> "_models.PrivateEndpointConnection": """Creates or updates PrivateEndpointConnections of service namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -153,39 +322,35 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PrivateEndpointConnection') - 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) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + namespace_name=namespace_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -198,64 +363,62 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - def _delete_initial( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + + def _delete_initial( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - def begin_delete( + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes an existing Private Endpoint Connection. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -266,14 +429,17 @@ def begin_delete( :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( @@ -286,25 +452,18 @@ def begin_delete( resource_group_name=resource_group_name, namespace_name=namespace_name, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -314,18 +473,18 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - namespace_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateEndpointConnection" + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> "_models.PrivateEndpointConnection": """Gets a description for the specified Private Endpoint Connection. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -344,34 +503,31 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) @@ -380,4 +536,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_private_link_resources_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_private_link_resources_operations.py index 31b03f9077eb..214fb817f5fc 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_private_link_resources_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_private_link_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,59 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class PrivateLinkResourcesOperations(object): """PrivateLinkResourcesOperations operations. @@ -44,13 +82,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateLinkResourcesListResult" + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> "_models.PrivateLinkResourcesListResult": """Gets lists of resources that supports Privatelinks. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -67,33 +105,30 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PrivateLinkResourcesListResult', pipeline_response) @@ -102,4 +137,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_queues_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_queues_operations.py index 27e537b793a3..f7e36e16f83f 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_queues_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_queues_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,444 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_authorization_rules_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_keys_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_regenerate_keys_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_namespace_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + *, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if skip is not None: + _query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + if top is not None: + _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class QueuesOperations(object): """QueuesOperations operations. @@ -45,14 +467,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_authorization_rules( self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SBAuthorizationRuleListResult"] + resource_group_name: str, + namespace_name: str, + queue_name: str, + **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRuleListResult"]: """Gets all authorization rules for a queue. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -62,46 +484,50 @@ def list_authorization_rules( :param queue_name: The queue name. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRuleListResult] + :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SBAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,31 +536,36 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules"} # type: ignore + @distributed_trace def create_or_update_authorization_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - authorization_rule_name, # type: str - parameters, # type: "_models.SBAuthorizationRule" - **kwargs # type: Any - ): - # type: (...) -> "_models.SBAuthorizationRule" + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: "_models.SBAuthorizationRule", + **kwargs: Any + ) -> "_models.SBAuthorizationRule": """Creates an authorization rule for a queue. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -157,40 +588,36 @@ def create_or_update_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBAuthorizationRule') - 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) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBAuthorizationRule') + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -199,17 +626,19 @@ def create_or_update_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}'} # type: ignore - def delete_authorization_rule( + create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace + def delete_authorization_rule( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> None: """Deletes a queue authorization rule. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -230,51 +659,49 @@ def delete_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}'} # type: ignore + delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + @distributed_trace def get_authorization_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SBAuthorizationRule" + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.SBAuthorizationRule": """Gets an authorization rule for a queue by rule name. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -295,35 +722,32 @@ def get_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -332,17 +756,19 @@ def get_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}'} # type: ignore + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace def list_keys( self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessKeys" + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.AccessKeys": """Primary and secondary connection strings to the queue. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -363,35 +789,32 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -400,18 +823,20 @@ def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore + + + @distributed_trace def regenerate_keys( self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - authorization_rule_name, # type: str - parameters, # type: "_models.RegenerateAccessKeyParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessKeys" + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: "_models.RegenerateAccessKeyParameters", + **kwargs: Any + ) -> "_models.AccessKeys": """Regenerates the primary or secondary connection strings to the queue. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -423,7 +848,8 @@ def regenerate_keys( :param authorization_rule_name: The authorization rule name. :type authorization_rule_name: str :param parameters: Parameters supplied to regenerate the authorization rule. - :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.RegenerateAccessKeyParameters + :type parameters: + ~azure.mgmt.servicebus.v2018_01_01_preview.models.RegenerateAccessKeyParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessKeys, or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys @@ -434,40 +860,36 @@ def regenerate_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -476,17 +898,19 @@ def regenerate_keys( return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys'} # type: ignore + regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + + + @distributed_trace def list_by_namespace( self, - resource_group_name, # type: str - namespace_name, # type: str - skip=None, # type: Optional[int] - top=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SBQueueListResult"] + resource_group_name: str, + namespace_name: str, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.SBQueueListResult"]: """Gets the queues within a namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -495,54 +919,57 @@ def list_by_namespace( :type namespace_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. + parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip: int :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SBQueueListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBQueueListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBQueueListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBQueueListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_namespace.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', maximum=1000, minimum=0) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=self.list_by_namespace.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SBQueueListResult', pipeline_response) + deserialized = self._deserialize("SBQueueListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -551,30 +978,35 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_namespace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues'} # type: ignore + list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues"} # type: ignore + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - parameters, # type: "_models.SBQueue" - **kwargs # type: Any - ): - # type: (...) -> "_models.SBQueue" + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: "_models.SBQueue", + **kwargs: Any + ) -> "_models.SBQueue": """Creates or updates a Service Bus queue. This operation is idempotent. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -595,39 +1027,35 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBQueue') - 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) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBQueue') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBQueue', pipeline_response) @@ -636,16 +1064,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}'} # type: ignore - def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + queue_name: str, + **kwargs: Any + ) -> None: """Deletes a queue from the specified namespace in a resource group. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -664,49 +1094,47 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SBQueue" + resource_group_name: str, + namespace_name: str, + queue_name: str, + **kwargs: Any + ) -> "_models.SBQueue": """Returns a description for the specified queue. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -725,34 +1153,31 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBQueue', pipeline_response) @@ -761,4 +1186,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_regions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_regions_operations.py index ace530c758f4..0a13b0af48bc 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_regions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_regions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,58 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_sku_request( + subscription_id: str, + sku: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/sku/{sku}/regions") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "sku": _SERIALIZER.url("sku", sku, 'str', max_length=50, min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class RegionsOperations(object): """RegionsOperations operations. @@ -45,55 +81,57 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_sku( self, - sku, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PremiumMessagingRegionsListResult"] + sku: str, + **kwargs: Any + ) -> Iterable["_models.PremiumMessagingRegionsListResult"]: """Gets the available Regions for a given sku. :param sku: The sku type. :type sku: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PremiumMessagingRegionsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.PremiumMessagingRegionsListResult] + :return: An iterator like instance of either PremiumMessagingRegionsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.PremiumMessagingRegionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.PremiumMessagingRegionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_sku.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'sku': self._serialize.url("sku", sku, 'str', max_length=50, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_sku_request( + subscription_id=self._config.subscription_id, + sku=sku, + api_version=api_version, + template_url=self.list_by_sku.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_sku_request( + subscription_id=self._config.subscription_id, + sku=sku, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PremiumMessagingRegionsListResult', pipeline_response) + deserialized = self._deserialize("PremiumMessagingRegionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -102,17 +140,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_sku.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/sku/{sku}/regions'} # type: ignore + list_by_sku.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/sku/{sku}/regions"} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_rules_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_rules_operations.py index 95a2757bad7a..62be23ae687b 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_rules_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_rules_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,206 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_subscriptions_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + subscription_id: str, + *, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if skip is not None: + _query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + if top is not None: + _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class RulesOperations(object): """RulesOperations operations. @@ -45,17 +229,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_subscriptions( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - subscription_name, # type: str - skip=None, # type: Optional[int] - top=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RuleListResult"] + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.RuleListResult"]: """List all the rules within given topic-subscription. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -68,56 +252,61 @@ def list_by_subscriptions( :type subscription_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. + parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip: int :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.RuleListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.RuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscriptions.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', maximum=1000, minimum=0) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscriptions_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=self.list_by_subscriptions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscriptions_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RuleListResult', pipeline_response) + deserialized = self._deserialize("RuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -126,32 +315,37 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_subscriptions.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules'} # type: ignore + list_by_subscriptions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules"} # type: ignore + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - subscription_name, # type: str - rule_name, # type: str - parameters, # type: "_models.Rule" - **kwargs # type: Any - ): - # type: (...) -> "_models.Rule" + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: "_models.Rule", + **kwargs: Any + ) -> "_models.Rule": """Creates a new rule and updates an existing rule. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -176,41 +370,37 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Rule') - 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) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Rule') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Rule', pipeline_response) @@ -219,18 +409,20 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}'} # type: ignore - def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - subscription_name, # type: str - rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + **kwargs: Any + ) -> None: """Deletes an existing rule. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -253,53 +445,51 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - subscription_name, # type: str - rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Rule" + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + **kwargs: Any + ) -> "_models.Rule": """Retrieves the description for the specified rule. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -322,36 +512,33 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Rule', pipeline_response) @@ -360,4 +547,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_subscriptions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_subscriptions_operations.py index 47771b2005d1..c3167a1a3d56 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_subscriptions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_subscriptions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,198 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_topic_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_id: str, + *, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if skip is not None: + _query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + if top is not None: + _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class SubscriptionsOperations(object): """SubscriptionsOperations operations. @@ -45,16 +221,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_topic( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - skip=None, # type: Optional[int] - top=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SBSubscriptionListResult"] + resource_group_name: str, + namespace_name: str, + topic_name: str, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.SBSubscriptionListResult"]: """List all the subscriptions under a specified topic. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -65,55 +241,60 @@ def list_by_topic( :type topic_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. + parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip: int :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBSubscriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSubscriptionListResult] + :return: An iterator like instance of either SBSubscriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSubscriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBSubscriptionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_topic.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', maximum=1000, minimum=0) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_topic_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=self.list_by_topic.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_topic_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SBSubscriptionListResult', pipeline_response) + deserialized = self._deserialize("SBSubscriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -122,31 +303,36 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_topic.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions'} # type: ignore + list_by_topic.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions"} # type: ignore + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - subscription_name, # type: str - parameters, # type: "_models.SBSubscription" - **kwargs # type: Any - ): - # type: (...) -> "_models.SBSubscription" + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: "_models.SBSubscription", + **kwargs: Any + ) -> "_models.SBSubscription": """Creates a topic subscription. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -169,40 +355,36 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBSubscription') - 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) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBSubscription') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBSubscription', pipeline_response) @@ -211,17 +393,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}'} # type: ignore - def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - subscription_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + **kwargs: Any + ) -> None: """Deletes a subscription from the specified topic. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -242,51 +426,49 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - subscription_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SBSubscription" + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + **kwargs: Any + ) -> "_models.SBSubscription": """Returns a subscription description for the specified topic. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -307,35 +489,32 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBSubscription', pipeline_response) @@ -344,4 +523,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_topics_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_topics_operations.py index b054849d6640..1bfd10eddd14 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_topics_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_topics_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,444 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_authorization_rules_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_delete_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_keys_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_regenerate_keys_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_namespace_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + *, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if skip is not None: + _query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + if top is not None: + _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class TopicsOperations(object): """TopicsOperations operations. @@ -45,14 +467,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_authorization_rules( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SBAuthorizationRuleListResult"] + resource_group_name: str, + namespace_name: str, + topic_name: str, + **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRuleListResult"]: """Gets authorization rules for a topic. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -62,46 +484,50 @@ def list_authorization_rules( :param topic_name: The topic name. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRuleListResult] + :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SBAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,31 +536,36 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules"} # type: ignore + @distributed_trace def create_or_update_authorization_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - authorization_rule_name, # type: str - parameters, # type: "_models.SBAuthorizationRule" - **kwargs # type: Any - ): - # type: (...) -> "_models.SBAuthorizationRule" + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: "_models.SBAuthorizationRule", + **kwargs: Any + ) -> "_models.SBAuthorizationRule": """Creates an authorization rule for the specified topic. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -157,40 +588,36 @@ def create_or_update_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBAuthorizationRule') - 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) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBAuthorizationRule') + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -199,17 +626,19 @@ def create_or_update_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}'} # type: ignore + create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace def get_authorization_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SBAuthorizationRule" + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.SBAuthorizationRule": """Returns the specified authorization rule. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -230,35 +659,32 @@ def get_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -267,17 +693,19 @@ def get_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}'} # type: ignore - def delete_authorization_rule( + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace + def delete_authorization_rule( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> None: """Deletes a topic authorization rule. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -298,51 +726,49 @@ def delete_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}'} # type: ignore + delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + @distributed_trace def list_keys( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessKeys" + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.AccessKeys": """Gets the primary and secondary connection strings for the topic. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -363,35 +789,32 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -400,18 +823,20 @@ def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore + + + @distributed_trace def regenerate_keys( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - authorization_rule_name, # type: str - parameters, # type: "_models.RegenerateAccessKeyParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessKeys" + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: "_models.RegenerateAccessKeyParameters", + **kwargs: Any + ) -> "_models.AccessKeys": """Regenerates primary or secondary connection strings for the topic. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -423,7 +848,8 @@ def regenerate_keys( :param authorization_rule_name: The authorization rule name. :type authorization_rule_name: str :param parameters: Parameters supplied to regenerate the authorization rule. - :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.RegenerateAccessKeyParameters + :type parameters: + ~azure.mgmt.servicebus.v2018_01_01_preview.models.RegenerateAccessKeyParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessKeys, or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys @@ -434,40 +860,36 @@ def regenerate_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -476,17 +898,19 @@ def regenerate_keys( return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys'} # type: ignore + regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + + + @distributed_trace def list_by_namespace( self, - resource_group_name, # type: str - namespace_name, # type: str - skip=None, # type: Optional[int] - top=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SBTopicListResult"] + resource_group_name: str, + namespace_name: str, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.SBTopicListResult"]: """Gets all the topics in a namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -495,54 +919,57 @@ def list_by_namespace( :type namespace_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. + parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip: int :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SBTopicListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBTopicListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBTopicListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBTopicListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_namespace.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', maximum=1000, minimum=0) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=self.list_by_namespace.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SBTopicListResult', pipeline_response) + deserialized = self._deserialize("SBTopicListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -551,30 +978,35 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_namespace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics'} # type: ignore + list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics"} # type: ignore + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - parameters, # type: "_models.SBTopic" - **kwargs # type: Any - ): - # type: (...) -> "_models.SBTopic" + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: "_models.SBTopic", + **kwargs: Any + ) -> "_models.SBTopic": """Creates a topic in the specified namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -595,39 +1027,35 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBTopic') - 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) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBTopic') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBTopic', pipeline_response) @@ -636,16 +1064,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}'} # type: ignore - def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + topic_name: str, + **kwargs: Any + ) -> None: """Deletes a topic from the specified namespace and resource group. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -664,49 +1094,47 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SBTopic" + resource_group_name: str, + namespace_name: str, + topic_name: str, + **kwargs: Any + ) -> "_models.SBTopic": """Returns a description for the specified topic. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -725,34 +1153,31 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBTopic', pipeline_response) @@ -761,4 +1186,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/__init__.py index e6ef471ff03a..aa0384448e69 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ServiceBusManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_configuration.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_configuration.py index cd2268ebed1e..d78f9e92a5dc 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_configuration.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_configuration.py @@ -6,22 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -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 @@ -29,26 +27,31 @@ class ServiceBusManagementClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-01-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-01-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-servicebus/{}'.format(VERSION)) self._configure(**kwargs) @@ -68,4 +71,4 @@ def _configure( 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) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_metadata.json b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_metadata.json index 5d9ae13b9d1e..77f7bafcb300 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_metadata.json +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_metadata.json @@ -5,13 +5,13 @@ "name": "ServiceBusManagementClient", "filename": "_service_bus_management_client", "description": "Azure Service Bus client for managing Namespace.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "namespaces": "NamespacesOperations", diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_service_bus_management_client.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_service_bus_management_client.py index cead781c4999..5f7ca49a600a 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_service_bus_management_client.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_service_bus_management_client.py @@ -6,47 +6,41 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient -from ._configuration import ServiceBusManagementClientConfiguration -from .operations import NamespacesOperations -from .operations import PrivateEndpointConnectionsOperations -from .operations import PrivateLinkResourcesOperations -from .operations import Operations -from .operations import DisasterRecoveryConfigsOperations -from .operations import MigrationConfigsOperations -from .operations import QueuesOperations -from .operations import TopicsOperations -from .operations import RulesOperations -from .operations import SubscriptionsOperations from . import models +from ._configuration import ServiceBusManagementClientConfiguration +from .operations import DisasterRecoveryConfigsOperations, MigrationConfigsOperations, NamespacesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueuesOperations, RulesOperations, SubscriptionsOperations, TopicsOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class ServiceBusManagementClient(object): +class ServiceBusManagementClient: # pylint: disable=too-many-instance-attributes """Azure Service Bus client for managing Namespace. :ivar namespaces: NamespacesOperations operations :vartype namespaces: azure.mgmt.servicebus.v2021_01_01_preview.operations.NamespacesOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: azure.mgmt.servicebus.v2021_01_01_preview.operations.PrivateEndpointConnectionsOperations + :vartype private_endpoint_connections: + azure.mgmt.servicebus.v2021_01_01_preview.operations.PrivateEndpointConnectionsOperations :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: azure.mgmt.servicebus.v2021_01_01_preview.operations.PrivateLinkResourcesOperations + :vartype private_link_resources: + azure.mgmt.servicebus.v2021_01_01_preview.operations.PrivateLinkResourcesOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.servicebus.v2021_01_01_preview.operations.Operations :ivar disaster_recovery_configs: DisasterRecoveryConfigsOperations operations - :vartype disaster_recovery_configs: azure.mgmt.servicebus.v2021_01_01_preview.operations.DisasterRecoveryConfigsOperations + :vartype disaster_recovery_configs: + azure.mgmt.servicebus.v2021_01_01_preview.operations.DisasterRecoveryConfigsOperations :ivar migration_configs: MigrationConfigsOperations operations - :vartype migration_configs: azure.mgmt.servicebus.v2021_01_01_preview.operations.MigrationConfigsOperations + :vartype migration_configs: + azure.mgmt.servicebus.v2021_01_01_preview.operations.MigrationConfigsOperations :ivar queues: QueuesOperations operations :vartype queues: azure.mgmt.servicebus.v2021_01_01_preview.operations.QueuesOperations :ivar topics: TopicsOperations operations @@ -54,71 +48,73 @@ class ServiceBusManagementClient(object): :ivar rules: RulesOperations operations :vartype rules: azure.mgmt.servicebus.v2021_01_01_preview.operations.RulesOperations :ivar subscriptions: SubscriptionsOperations operations - :vartype subscriptions: azure.mgmt.servicebus.v2021_01_01_preview.operations.SubscriptionsOperations + :vartype subscriptions: + azure.mgmt.servicebus.v2021_01_01_preview.operations.SubscriptionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2021-01-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ServiceBusManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ServiceBusManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - - self.namespaces = NamespacesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.disaster_recovery_configs = DisasterRecoveryConfigsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.migration_configs = MigrationConfigsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.queues = QueuesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.topics = TopicsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.rules = RulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + self._serialize.client_side_validation = False + self.namespaces = NamespacesOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.disaster_recovery_configs = DisasterRecoveryConfigsOperations(self._client, self._config, self._serialize, self._deserialize) + self.migration_configs = MigrationConfigsOperations(self._client, self._config, self._serialize, self._deserialize) + self.queues = QueuesOperations(self._client, self._config, self._serialize, self._deserialize) + self.topics = TopicsOperations(self._client, self._config, self._serialize, self._deserialize) + self.rules = RulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations(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. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_vendor.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# 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 azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_version.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_version.py index e7ffc58c0429..e5754a47ce68 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_version.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "7.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/__init__.py index 9016cbc21795..1b5398b4946f 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/__init__.py @@ -8,3 +8,8 @@ from ._service_bus_management_client import ServiceBusManagementClient __all__ = ['ServiceBusManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/_configuration.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/_configuration.py index 6a63626a4243..52f2360f8f02 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/_configuration.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -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 @@ -27,8 +27,12 @@ class ServiceBusManagementClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-01-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -37,15 +41,17 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-01-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-servicebus/{}'.format(VERSION)) self._configure(**kwargs) @@ -64,4 +70,4 @@ def _configure( 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) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/_service_bus_management_client.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/_service_bus_management_client.py index 19ce1a02e97d..0b1aa7f86566 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/_service_bus_management_client.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/_service_bus_management_client.py @@ -6,45 +6,42 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient -from ._configuration import ServiceBusManagementClientConfiguration -from .operations import NamespacesOperations -from .operations import PrivateEndpointConnectionsOperations -from .operations import PrivateLinkResourcesOperations -from .operations import Operations -from .operations import DisasterRecoveryConfigsOperations -from .operations import MigrationConfigsOperations -from .operations import QueuesOperations -from .operations import TopicsOperations -from .operations import RulesOperations -from .operations import SubscriptionsOperations from .. import models +from ._configuration import ServiceBusManagementClientConfiguration +from .operations import DisasterRecoveryConfigsOperations, MigrationConfigsOperations, NamespacesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueuesOperations, RulesOperations, SubscriptionsOperations, TopicsOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class ServiceBusManagementClient(object): +class ServiceBusManagementClient: # pylint: disable=too-many-instance-attributes """Azure Service Bus client for managing Namespace. :ivar namespaces: NamespacesOperations operations - :vartype namespaces: azure.mgmt.servicebus.v2021_01_01_preview.aio.operations.NamespacesOperations + :vartype namespaces: + azure.mgmt.servicebus.v2021_01_01_preview.aio.operations.NamespacesOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: azure.mgmt.servicebus.v2021_01_01_preview.aio.operations.PrivateEndpointConnectionsOperations + :vartype private_endpoint_connections: + azure.mgmt.servicebus.v2021_01_01_preview.aio.operations.PrivateEndpointConnectionsOperations :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: azure.mgmt.servicebus.v2021_01_01_preview.aio.operations.PrivateLinkResourcesOperations + :vartype private_link_resources: + azure.mgmt.servicebus.v2021_01_01_preview.aio.operations.PrivateLinkResourcesOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.servicebus.v2021_01_01_preview.aio.operations.Operations :ivar disaster_recovery_configs: DisasterRecoveryConfigsOperations operations - :vartype disaster_recovery_configs: azure.mgmt.servicebus.v2021_01_01_preview.aio.operations.DisasterRecoveryConfigsOperations + :vartype disaster_recovery_configs: + azure.mgmt.servicebus.v2021_01_01_preview.aio.operations.DisasterRecoveryConfigsOperations :ivar migration_configs: MigrationConfigsOperations operations - :vartype migration_configs: azure.mgmt.servicebus.v2021_01_01_preview.aio.operations.MigrationConfigsOperations + :vartype migration_configs: + azure.mgmt.servicebus.v2021_01_01_preview.aio.operations.MigrationConfigsOperations :ivar queues: QueuesOperations operations :vartype queues: azure.mgmt.servicebus.v2021_01_01_preview.aio.operations.QueuesOperations :ivar topics: TopicsOperations operations @@ -52,69 +49,73 @@ class ServiceBusManagementClient(object): :ivar rules: RulesOperations operations :vartype rules: azure.mgmt.servicebus.v2021_01_01_preview.aio.operations.RulesOperations :ivar subscriptions: SubscriptionsOperations operations - :vartype subscriptions: azure.mgmt.servicebus.v2021_01_01_preview.aio.operations.SubscriptionsOperations + :vartype subscriptions: + azure.mgmt.servicebus.v2021_01_01_preview.aio.operations.SubscriptionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2021-01-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = ServiceBusManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ServiceBusManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.namespaces = NamespacesOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.disaster_recovery_configs = DisasterRecoveryConfigsOperations(self._client, self._config, self._serialize, self._deserialize) + self.migration_configs = MigrationConfigsOperations(self._client, self._config, self._serialize, self._deserialize) + self.queues = QueuesOperations(self._client, self._config, self._serialize, self._deserialize) + self.topics = TopicsOperations(self._client, self._config, self._serialize, self._deserialize) + self.rules = RulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.namespaces = NamespacesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.disaster_recovery_configs = DisasterRecoveryConfigsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.migration_configs = MigrationConfigsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.queues = QueuesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.topics = TopicsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.rules = RulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_disaster_recovery_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_disaster_recovery_configs_operations.py index bea5494b1ccd..fbf1b88266d2 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_disaster_recovery_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_disaster_recovery_configs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._disaster_recovery_configs_operations import build_break_pairing_request, build_check_name_availability_request, build_create_or_update_request, build_delete_request, build_fail_over_request, build_get_authorization_rule_request, build_get_request, build_list_authorization_rules_request, build_list_keys_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def check_name_availability( self, resource_group_name: str, @@ -66,38 +71,34 @@ async def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CheckNameAvailability') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'CheckNameAvailability') + + request = build_check_name_availability_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) @@ -106,8 +107,11 @@ async def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability"} # type: ignore + + + @distributed_trace def list( self, resource_group_name: str, @@ -121,45 +125,48 @@ def list( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ArmDisasterRecoveryListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.ArmDisasterRecoveryListResult] + :return: An iterator like instance of either ArmDisasterRecoveryListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.ArmDisasterRecoveryListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ArmDisasterRecoveryListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ArmDisasterRecoveryListResult', pipeline_response) + deserialized = self._deserialize("ArmDisasterRecoveryListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -168,21 +175,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs"} # type: ignore + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -211,39 +224,35 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ArmDisasterRecovery') - 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) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ArmDisasterRecovery') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -254,9 +263,12 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}'} # type: ignore - async def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -281,41 +293,40 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -341,34 +352,31 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) @@ -377,9 +385,12 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}'} # type: ignore - async def break_pairing( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore + + + @distributed_trace_async + async def break_pairing( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -405,42 +416,41 @@ async def break_pairing( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.break_pairing.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_break_pairing_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.break_pairing.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - break_pairing.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing'} # type: ignore + break_pairing.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing"} # type: ignore - async def fail_over( + + @distributed_trace_async + async def fail_over( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -457,6 +467,7 @@ async def fail_over( :param alias: The Disaster Recovery configuration name. :type alias: str :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Default value is None. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.FailoverProperties :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) @@ -468,49 +479,47 @@ async def fail_over( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.fail_over.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if parameters is not None: - body_content = self._serialize.body(parameters, 'FailoverProperties') + _json = self._serialize.body(parameters, 'FailoverProperties') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + _json = None + + request = build_fail_over_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.fail_over.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - fail_over.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover'} # type: ignore + fail_over.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover"} # type: ignore + + @distributed_trace def list_authorization_rules( self, resource_group_name: str, @@ -527,46 +536,50 @@ def list_authorization_rules( :param alias: The Disaster Recovery configuration name. :type alias: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRuleListResult] + :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SBAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -575,21 +588,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules"} # type: ignore + @distributed_trace_async async def get_authorization_rule( self, resource_group_name: str, @@ -618,35 +637,32 @@ async def get_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -655,8 +671,11 @@ async def get_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}'} # type: ignore + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace_async async def list_keys( self, resource_group_name: str, @@ -685,35 +704,32 @@ async def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -722,4 +738,6 @@ async def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys'} # type: ignore + + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_migration_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_migration_configs_operations.py index af381736c780..de1507ee00a9 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_migration_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_migration_configs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,19 +6,22 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._migration_configs_operations import build_complete_migration_request, build_create_and_start_migration_request_initial, build_delete_request, build_get_request, build_list_request, build_revert_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +47,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name: str, @@ -56,45 +61,48 @@ def list( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MigrationConfigListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigListResult] + :return: An iterator like instance of either MigrationConfigListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.MigrationConfigListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('MigrationConfigListResult', pipeline_response) + deserialized = self._deserialize("MigrationConfigListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,20 +111,25 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations"} # type: ignore async def _create_and_start_migration_initial( self, @@ -131,40 +144,35 @@ async def _create_and_start_migration_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_and_start_migration_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'MigrationConfigProperties') - 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) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'MigrationConfigProperties') + + request = build_create_and_start_migration_request_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_and_start_migration_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -174,8 +182,11 @@ async def _create_and_start_migration_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_and_start_migration_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}'} # type: ignore + _create_and_start_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + + + @distributed_trace_async async def begin_create_and_start_migration( self, resource_group_name: str, @@ -192,19 +203,26 @@ async def begin_create_and_start_migration( :param namespace_name: The namespace name. :type namespace_name: str :param config_name: The configuration name. Should always be "$default". - :type config_name: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigurationName + :type config_name: str or + ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigurationName :param parameters: Parameters required to create Migration Configuration. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigProperties :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either MigrationConfigProperties or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigProperties] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MigrationConfigProperties or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigProperties] + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.MigrationConfigProperties"] lro_delay = kwargs.pop( @@ -218,28 +236,22 @@ async def begin_create_and_start_migration( namespace_name=namespace_name, config_name=config_name, parameters=parameters, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -249,11 +261,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_and_start_migration.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_and_start_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore - async def delete( + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -267,7 +280,8 @@ async def delete( :param namespace_name: The namespace name. :type namespace_name: str :param config_name: The configuration name. Should always be "$default". - :type config_name: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigurationName + :type config_name: str or + ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigurationName :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -278,41 +292,40 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -327,7 +340,8 @@ async def get( :param namespace_name: The namespace name. :type namespace_name: str :param config_name: The configuration name. Should always be "$default". - :type config_name: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigurationName + :type config_name: str or + ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigurationName :keyword callable cls: A custom type or function that will be passed the direct response :return: MigrationConfigProperties, or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigProperties @@ -338,34 +352,31 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) @@ -374,9 +385,12 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}'} # type: ignore - async def complete_migration( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + + + @distributed_trace_async + async def complete_migration( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -392,7 +406,8 @@ async def complete_migration( :param namespace_name: The namespace name. :type namespace_name: str :param config_name: The configuration name. Should always be "$default". - :type config_name: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigurationName + :type config_name: str or + ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigurationName :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -403,42 +418,41 @@ async def complete_migration( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.complete_migration.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_complete_migration_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.complete_migration.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - complete_migration.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade'} # type: ignore + complete_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade"} # type: ignore - async def revert( + + @distributed_trace_async + async def revert( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -452,7 +466,8 @@ async def revert( :param namespace_name: The namespace name. :type namespace_name: str :param config_name: The configuration name. Should always be "$default". - :type config_name: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigurationName + :type config_name: str or + ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigurationName :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -463,37 +478,35 @@ async def revert( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.revert.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_revert_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.revert.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - revert.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert'} # type: ignore + revert.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_namespaces_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_namespaces_operations.py index 506193bae4f7..68e9d56bf2e5 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_namespaces_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_namespaces_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,19 +6,22 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._namespaces_operations import build_check_name_availability_request, build_create_or_update_authorization_rule_request, build_create_or_update_network_rule_set_request, build_create_or_update_request_initial, build_delete_authorization_rule_request, build_delete_request_initial, build_get_authorization_rule_request, build_get_network_rule_set_request, build_get_request, build_list_authorization_rules_request, build_list_by_resource_group_request, build_list_keys_request, build_list_network_rule_sets_request, build_list_request, build_regenerate_keys_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +47,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -50,43 +55,44 @@ def list( """Gets all the available namespaces within the subscription, irrespective of the resource groups. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBNamespaceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespaceListResult] + :return: An iterator like instance of either SBNamespaceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespaceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBNamespaceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SBNamespaceListResult', pipeline_response) + deserialized = self._deserialize("SBNamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -95,21 +101,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces"} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -120,44 +132,46 @@ def list_by_resource_group( :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBNamespaceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespaceListResult] + :return: An iterator like instance of either SBNamespaceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespaceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBNamespaceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SBNamespaceListResult', pipeline_response) + deserialized = self._deserialize("SBNamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -166,20 +180,25 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces"} # type: ignore async def _create_or_update_initial( self, @@ -193,39 +212,34 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBNamespace') - 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) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBNamespace') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -238,8 +252,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -258,14 +275,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either SBNamespace or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either SBNamespace or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace] + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.SBNamespace"] lro_delay = kwargs.pop( @@ -278,27 +301,22 @@ async def begin_create_or_update( resource_group_name=resource_group_name, namespace_name=namespace_name, parameters=parameters, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('SBNamespace', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -308,11 +326,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - async def _delete_initial( + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -323,41 +341,39 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - async def begin_delete( + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -372,14 +388,17 @@ async def begin_delete( :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( @@ -391,24 +410,18 @@ async def begin_delete( raw_result = await self._delete_initial( resource_group_name=resource_group_name, namespace_name=namespace_name, + api_version=api_version, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -418,10 +431,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -444,33 +458,30 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBNamespace', pipeline_response) @@ -479,8 +490,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -507,38 +521,34 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -552,8 +562,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + + @distributed_trace_async async def create_or_update_network_rule_set( self, resource_group_name: str, @@ -579,38 +592,34 @@ async def create_or_update_network_rule_set( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_network_rule_set.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'NetworkRuleSet') - 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) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'NetworkRuleSet') + + request = build_create_or_update_network_rule_set_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_network_rule_set.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('NetworkRuleSet', pipeline_response) @@ -619,8 +628,11 @@ async def create_or_update_network_rule_set( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_network_rule_set.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default'} # type: ignore + create_or_update_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore + + + @distributed_trace_async async def get_network_rule_set( self, resource_group_name: str, @@ -643,33 +655,30 @@ async def get_network_rule_set( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_network_rule_set.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_network_rule_set_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_network_rule_set.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('NetworkRuleSet', pipeline_response) @@ -678,8 +687,11 @@ async def get_network_rule_set( return cls(pipeline_response, deserialized, {}) return deserialized - get_network_rule_set.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default'} # type: ignore + get_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore + + + @distributed_trace def list_network_rule_sets( self, resource_group_name: str, @@ -693,45 +705,48 @@ def list_network_rule_sets( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NetworkRuleSetListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleSetListResult] + :return: An iterator like instance of either NetworkRuleSetListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkRuleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_network_rule_sets.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_network_rule_sets_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_network_rule_sets.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_network_rule_sets_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('NetworkRuleSetListResult', pipeline_response) + deserialized = self._deserialize("NetworkRuleSetListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -740,21 +755,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_network_rule_sets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets'} # type: ignore + list_network_rule_sets.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets"} # type: ignore + @distributed_trace def list_authorization_rules( self, resource_group_name: str, @@ -768,45 +789,48 @@ def list_authorization_rules( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRuleListResult] + :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SBAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -815,21 +839,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules"} # type: ignore + @distributed_trace_async async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -858,39 +888,35 @@ async def create_or_update_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBAuthorizationRule') - 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) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBAuthorizationRule') + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -899,9 +925,12 @@ async def create_or_update_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}'} # type: ignore - async def delete_authorization_rule( + create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace_async + async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -926,41 +955,40 @@ async def delete_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}'} # type: ignore + delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore + + @distributed_trace_async async def get_authorization_rule( self, resource_group_name: str, @@ -986,34 +1014,31 @@ async def get_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -1022,8 +1047,11 @@ async def get_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}'} # type: ignore + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace_async async def list_keys( self, resource_group_name: str, @@ -1049,34 +1077,31 @@ async def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -1085,8 +1110,11 @@ async def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore + + + @distributed_trace_async async def regenerate_keys( self, resource_group_name: str, @@ -1104,7 +1132,8 @@ async def regenerate_keys( :param authorization_rule_name: The authorization rule name. :type authorization_rule_name: str :param parameters: Parameters supplied to regenerate the authorization rule. - :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.RegenerateAccessKeyParameters + :type parameters: + ~azure.mgmt.servicebus.v2021_01_01_preview.models.RegenerateAccessKeyParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessKeys, or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys @@ -1115,39 +1144,35 @@ async def regenerate_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -1156,8 +1181,11 @@ async def regenerate_keys( return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys'} # type: ignore + regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + + + @distributed_trace_async async def check_name_availability( self, parameters: "_models.CheckNameAvailability", @@ -1177,36 +1205,32 @@ async def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CheckNameAvailability') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'CheckNameAvailability') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) @@ -1215,4 +1239,6 @@ async def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability'} # type: ignore + + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_operations.py index e6ea2cbe3aec..4ef2d7c86a12 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,19 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,38 +53,40 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -89,17 +95,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.ServiceBus/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.ServiceBus/operations"} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_private_endpoint_connections_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_private_endpoint_connections_operations.py index c45008bfb2bb..6b49cf065aee 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_private_endpoint_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,19 +6,22 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._private_endpoint_connections_operations import build_create_or_update_request, build_delete_request_initial, build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +47,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name: str, @@ -56,45 +61,48 @@ def list( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateEndpointConnectionListResult] + :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PrivateEndpointConnectionListResult', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,21 +111,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections"} # type: ignore + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -147,39 +161,35 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PrivateEndpointConnection') - 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) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + namespace_name=namespace_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -192,9 +202,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - async def _delete_initial( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -206,42 +218,40 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + - async def begin_delete( + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -258,14 +268,17 @@ async def begin_delete( :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( @@ -278,25 +291,18 @@ async def begin_delete( resource_group_name=resource_group_name, namespace_name=namespace_name, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -306,10 +312,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -335,34 +342,31 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) @@ -371,4 +375,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_private_link_resources_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_private_link_resources_operations.py index 9cd5c0958ba1..510d55c64fb8 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_private_link_resources_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_private_link_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,16 +6,18 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._private_link_resources_operations import build_get_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +43,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -62,33 +66,30 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PrivateLinkResourcesListResult', pipeline_response) @@ -97,4 +98,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_queues_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_queues_operations.py index 7e68a14f9130..fa22382d5e6c 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_queues_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_queues_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._queues_operations import build_create_or_update_authorization_rule_request, build_create_or_update_request, build_delete_authorization_rule_request, build_delete_request, build_get_authorization_rule_request, build_get_request, build_list_authorization_rules_request, build_list_by_namespace_request, build_list_keys_request, build_regenerate_keys_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_authorization_rules( self, resource_group_name: str, @@ -57,46 +62,50 @@ def list_authorization_rules( :param queue_name: The queue name. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRuleListResult] + :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SBAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,21 +114,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules"} # type: ignore + @distributed_trace_async async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -151,40 +166,36 @@ async def create_or_update_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBAuthorizationRule') - 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) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBAuthorizationRule') + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -193,9 +204,12 @@ async def create_or_update_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}'} # type: ignore - async def delete_authorization_rule( + create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace_async + async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -223,42 +237,41 @@ async def delete_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}'} # type: ignore + delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + @distributed_trace_async async def get_authorization_rule( self, resource_group_name: str, @@ -287,35 +300,32 @@ async def get_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -324,8 +334,11 @@ async def get_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}'} # type: ignore + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace_async async def list_keys( self, resource_group_name: str, @@ -354,35 +367,32 @@ async def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -391,8 +401,11 @@ async def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore + + + @distributed_trace_async async def regenerate_keys( self, resource_group_name: str, @@ -413,7 +426,8 @@ async def regenerate_keys( :param authorization_rule_name: The authorization rule name. :type authorization_rule_name: str :param parameters: Parameters supplied to regenerate the authorization rule. - :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.RegenerateAccessKeyParameters + :type parameters: + ~azure.mgmt.servicebus.v2021_01_01_preview.models.RegenerateAccessKeyParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessKeys, or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys @@ -424,40 +438,36 @@ async def regenerate_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -466,8 +476,11 @@ async def regenerate_keys( return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys'} # type: ignore + regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + + + @distributed_trace def list_by_namespace( self, resource_group_name: str, @@ -484,54 +497,57 @@ def list_by_namespace( :type namespace_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. + parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip: int :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SBQueueListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBQueueListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBQueueListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBQueueListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_namespace.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', maximum=1000, minimum=0) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=self.list_by_namespace.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SBQueueListResult', pipeline_response) + deserialized = self._deserialize("SBQueueListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -540,21 +556,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_namespace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues'} # type: ignore + list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues"} # type: ignore + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -583,39 +605,35 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBQueue') - 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) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBQueue') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBQueue', pipeline_response) @@ -624,9 +642,12 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}'} # type: ignore - async def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -651,41 +672,40 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -711,34 +731,31 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBQueue', pipeline_response) @@ -747,4 +764,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_rules_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_rules_operations.py index ac8359450bc9..ea0d10aa42c2 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_rules_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_rules_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._rules_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_subscriptions_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_subscriptions( self, resource_group_name: str, @@ -63,56 +68,61 @@ def list_by_subscriptions( :type subscription_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. + parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip: int :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.RuleListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.RuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscriptions.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', maximum=1000, minimum=0) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscriptions_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=self.list_by_subscriptions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscriptions_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RuleListResult', pipeline_response) + deserialized = self._deserialize("RuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -121,21 +131,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_subscriptions.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules'} # type: ignore + list_by_subscriptions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules"} # type: ignore + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -170,41 +186,37 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Rule') - 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) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Rule') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Rule', pipeline_response) @@ -213,9 +225,12 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}'} # type: ignore - async def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -246,43 +261,42 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -314,36 +328,33 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Rule', pipeline_response) @@ -352,4 +363,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_subscriptions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_subscriptions_operations.py index bfe16b0bb5f3..15e945ca9e73 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_subscriptions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_subscriptions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._subscriptions_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_topic_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_topic( self, resource_group_name: str, @@ -60,55 +65,60 @@ def list_by_topic( :type topic_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. + parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip: int :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBSubscriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSubscriptionListResult] + :return: An iterator like instance of either SBSubscriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSubscriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBSubscriptionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_topic.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', maximum=1000, minimum=0) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_topic_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=self.list_by_topic.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_topic_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SBSubscriptionListResult', pipeline_response) + deserialized = self._deserialize("SBSubscriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -117,21 +127,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_topic.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions'} # type: ignore + list_by_topic.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions"} # type: ignore + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -163,40 +179,36 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBSubscription') - 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) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBSubscription') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBSubscription', pipeline_response) @@ -205,9 +217,12 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}'} # type: ignore - async def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -235,42 +250,41 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -299,35 +313,32 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBSubscription', pipeline_response) @@ -336,4 +347,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_topics_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_topics_operations.py index e48cb8ef382a..8191ab74a92f 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_topics_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_topics_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._topics_operations import build_create_or_update_authorization_rule_request, build_create_or_update_request, build_delete_authorization_rule_request, build_delete_request, build_get_authorization_rule_request, build_get_request, build_list_authorization_rules_request, build_list_by_namespace_request, build_list_keys_request, build_regenerate_keys_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_authorization_rules( self, resource_group_name: str, @@ -57,46 +62,50 @@ def list_authorization_rules( :param topic_name: The topic name. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRuleListResult] + :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SBAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,21 +114,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules"} # type: ignore + @distributed_trace_async async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -151,40 +166,36 @@ async def create_or_update_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBAuthorizationRule') - 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) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBAuthorizationRule') + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -193,8 +204,11 @@ async def create_or_update_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}'} # type: ignore + create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace_async async def get_authorization_rule( self, resource_group_name: str, @@ -223,35 +237,32 @@ async def get_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -260,9 +271,12 @@ async def get_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}'} # type: ignore - async def delete_authorization_rule( + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace_async + async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -290,42 +304,41 @@ async def delete_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}'} # type: ignore + delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + @distributed_trace_async async def list_keys( self, resource_group_name: str, @@ -354,35 +367,32 @@ async def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -391,8 +401,11 @@ async def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore + + + @distributed_trace_async async def regenerate_keys( self, resource_group_name: str, @@ -413,7 +426,8 @@ async def regenerate_keys( :param authorization_rule_name: The authorization rule name. :type authorization_rule_name: str :param parameters: Parameters supplied to regenerate the authorization rule. - :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.RegenerateAccessKeyParameters + :type parameters: + ~azure.mgmt.servicebus.v2021_01_01_preview.models.RegenerateAccessKeyParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessKeys, or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys @@ -424,40 +438,36 @@ async def regenerate_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -466,8 +476,11 @@ async def regenerate_keys( return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys'} # type: ignore + regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + + + @distributed_trace def list_by_namespace( self, resource_group_name: str, @@ -484,54 +497,57 @@ def list_by_namespace( :type namespace_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. + parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip: int :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SBTopicListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBTopicListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBTopicListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBTopicListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_namespace.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', maximum=1000, minimum=0) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=self.list_by_namespace.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SBTopicListResult', pipeline_response) + deserialized = self._deserialize("SBTopicListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -540,21 +556,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_namespace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics'} # type: ignore + list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics"} # type: ignore + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -583,39 +605,35 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBTopic') - 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) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBTopic') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBTopic', pipeline_response) @@ -624,9 +642,12 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}'} # type: ignore - async def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -651,41 +672,40 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -711,34 +731,31 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBTopic', pipeline_response) @@ -747,4 +764,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/models/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/models/__init__.py index 4497cba42443..a418f97c10cc 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/models/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/models/__init__.py @@ -6,116 +6,61 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import AccessKeys - from ._models_py3 import Action - from ._models_py3 import ArmDisasterRecovery - from ._models_py3 import ArmDisasterRecoveryListResult - from ._models_py3 import CheckNameAvailability - from ._models_py3 import CheckNameAvailabilityResult - from ._models_py3 import ConnectionState - from ._models_py3 import CorrelationFilter - from ._models_py3 import DictionaryValue - from ._models_py3 import Encryption - from ._models_py3 import ErrorAdditionalInfo - from ._models_py3 import ErrorResponse - from ._models_py3 import ErrorResponseError - from ._models_py3 import FailoverProperties - from ._models_py3 import Identity - from ._models_py3 import KeyVaultProperties - from ._models_py3 import MessageCountDetails - from ._models_py3 import MigrationConfigListResult - from ._models_py3 import MigrationConfigProperties - from ._models_py3 import NWRuleSetIpRules - from ._models_py3 import NWRuleSetVirtualNetworkRules - from ._models_py3 import NetworkRuleSet - from ._models_py3 import NetworkRuleSetListResult - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationListResult - from ._models_py3 import PrivateEndpoint - from ._models_py3 import PrivateEndpointConnection - from ._models_py3 import PrivateEndpointConnectionListResult - from ._models_py3 import PrivateLinkResource - from ._models_py3 import PrivateLinkResourcesListResult - from ._models_py3 import RegenerateAccessKeyParameters - from ._models_py3 import Resource - from ._models_py3 import ResourceNamespacePatch - from ._models_py3 import Rule - from ._models_py3 import RuleListResult - from ._models_py3 import SBAuthorizationRule - from ._models_py3 import SBAuthorizationRuleListResult - from ._models_py3 import SBNamespace - from ._models_py3 import SBNamespaceListResult - from ._models_py3 import SBNamespaceUpdateParameters - from ._models_py3 import SBQueue - from ._models_py3 import SBQueueListResult - from ._models_py3 import SBSku - from ._models_py3 import SBSubscription - from ._models_py3 import SBSubscriptionListResult - from ._models_py3 import SBTopic - from ._models_py3 import SBTopicListResult - from ._models_py3 import SqlFilter - from ._models_py3 import SqlRuleAction - from ._models_py3 import Subnet - from ._models_py3 import SystemData - from ._models_py3 import TrackedResource - from ._models_py3 import UserAssignedIdentityProperties -except (SyntaxError, ImportError): - from ._models import AccessKeys # type: ignore - from ._models import Action # type: ignore - from ._models import ArmDisasterRecovery # type: ignore - from ._models import ArmDisasterRecoveryListResult # type: ignore - from ._models import CheckNameAvailability # type: ignore - from ._models import CheckNameAvailabilityResult # type: ignore - from ._models import ConnectionState # type: ignore - from ._models import CorrelationFilter # type: ignore - from ._models import DictionaryValue # type: ignore - from ._models import Encryption # type: ignore - from ._models import ErrorAdditionalInfo # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import ErrorResponseError # type: ignore - from ._models import FailoverProperties # type: ignore - from ._models import Identity # type: ignore - from ._models import KeyVaultProperties # type: ignore - from ._models import MessageCountDetails # type: ignore - from ._models import MigrationConfigListResult # type: ignore - from ._models import MigrationConfigProperties # type: ignore - from ._models import NWRuleSetIpRules # type: ignore - from ._models import NWRuleSetVirtualNetworkRules # type: ignore - from ._models import NetworkRuleSet # type: ignore - from ._models import NetworkRuleSetListResult # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import PrivateEndpoint # type: ignore - from ._models import PrivateEndpointConnection # type: ignore - from ._models import PrivateEndpointConnectionListResult # type: ignore - from ._models import PrivateLinkResource # type: ignore - from ._models import PrivateLinkResourcesListResult # type: ignore - from ._models import RegenerateAccessKeyParameters # type: ignore - from ._models import Resource # type: ignore - from ._models import ResourceNamespacePatch # type: ignore - from ._models import Rule # type: ignore - from ._models import RuleListResult # type: ignore - from ._models import SBAuthorizationRule # type: ignore - from ._models import SBAuthorizationRuleListResult # type: ignore - from ._models import SBNamespace # type: ignore - from ._models import SBNamespaceListResult # type: ignore - from ._models import SBNamespaceUpdateParameters # type: ignore - from ._models import SBQueue # type: ignore - from ._models import SBQueueListResult # type: ignore - from ._models import SBSku # type: ignore - from ._models import SBSubscription # type: ignore - from ._models import SBSubscriptionListResult # type: ignore - from ._models import SBTopic # type: ignore - from ._models import SBTopicListResult # type: ignore - from ._models import SqlFilter # type: ignore - from ._models import SqlRuleAction # type: ignore - from ._models import Subnet # type: ignore - from ._models import SystemData # type: ignore - from ._models import TrackedResource # type: ignore - from ._models import UserAssignedIdentityProperties # type: ignore +from ._models_py3 import AccessKeys +from ._models_py3 import Action +from ._models_py3 import ArmDisasterRecovery +from ._models_py3 import ArmDisasterRecoveryListResult +from ._models_py3 import CheckNameAvailability +from ._models_py3 import CheckNameAvailabilityResult +from ._models_py3 import ConnectionState +from ._models_py3 import CorrelationFilter +from ._models_py3 import DictionaryValue +from ._models_py3 import Encryption +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorResponse +from ._models_py3 import ErrorResponseError +from ._models_py3 import FailoverProperties +from ._models_py3 import Identity +from ._models_py3 import KeyVaultProperties +from ._models_py3 import MessageCountDetails +from ._models_py3 import MigrationConfigListResult +from ._models_py3 import MigrationConfigProperties +from ._models_py3 import NWRuleSetIpRules +from ._models_py3 import NWRuleSetVirtualNetworkRules +from ._models_py3 import NetworkRuleSet +from ._models_py3 import NetworkRuleSetListResult +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import PrivateEndpoint +from ._models_py3 import PrivateEndpointConnection +from ._models_py3 import PrivateEndpointConnectionListResult +from ._models_py3 import PrivateLinkResource +from ._models_py3 import PrivateLinkResourcesListResult +from ._models_py3 import RegenerateAccessKeyParameters +from ._models_py3 import Resource +from ._models_py3 import ResourceNamespacePatch +from ._models_py3 import Rule +from ._models_py3 import RuleListResult +from ._models_py3 import SBAuthorizationRule +from ._models_py3 import SBAuthorizationRuleListResult +from ._models_py3 import SBNamespace +from ._models_py3 import SBNamespaceListResult +from ._models_py3 import SBNamespaceUpdateParameters +from ._models_py3 import SBQueue +from ._models_py3 import SBQueueListResult +from ._models_py3 import SBSku +from ._models_py3 import SBSubscription +from ._models_py3 import SBSubscriptionListResult +from ._models_py3 import SBTopic +from ._models_py3 import SBTopicListResult +from ._models_py3 import SqlFilter +from ._models_py3 import SqlRuleAction +from ._models_py3 import Subnet +from ._models_py3 import SystemData +from ._models_py3 import TrackedResource +from ._models_py3 import UserAssignedIdentityProperties + from ._service_bus_management_client_enums import ( AccessRights, diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/models/_models.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/models/_models.py deleted file mode 100644 index 31655ef47e07..000000000000 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/models/_models.py +++ /dev/null @@ -1,2238 +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 azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class AccessKeys(msrest.serialization.Model): - """Namespace/ServiceBus Connection String. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar primary_connection_string: Primary connection string of the created namespace - authorization rule. - :vartype primary_connection_string: str - :ivar secondary_connection_string: Secondary connection string of the created namespace - authorization rule. - :vartype secondary_connection_string: str - :ivar alias_primary_connection_string: Primary connection string of the alias if GEO DR is - enabled. - :vartype alias_primary_connection_string: str - :ivar alias_secondary_connection_string: Secondary connection string of the alias if GEO DR is - enabled. - :vartype alias_secondary_connection_string: str - :ivar primary_key: A base64-encoded 256-bit primary key for signing and validating the SAS - token. - :vartype primary_key: str - :ivar secondary_key: A base64-encoded 256-bit primary key for signing and validating the SAS - token. - :vartype secondary_key: str - :ivar key_name: A string that describes the authorization rule. - :vartype key_name: str - """ - - _validation = { - 'primary_connection_string': {'readonly': True}, - 'secondary_connection_string': {'readonly': True}, - 'alias_primary_connection_string': {'readonly': True}, - 'alias_secondary_connection_string': {'readonly': True}, - 'primary_key': {'readonly': True}, - 'secondary_key': {'readonly': True}, - 'key_name': {'readonly': True}, - } - - _attribute_map = { - 'primary_connection_string': {'key': 'primaryConnectionString', 'type': 'str'}, - 'secondary_connection_string': {'key': 'secondaryConnectionString', 'type': 'str'}, - 'alias_primary_connection_string': {'key': 'aliasPrimaryConnectionString', 'type': 'str'}, - 'alias_secondary_connection_string': {'key': 'aliasSecondaryConnectionString', 'type': 'str'}, - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, - 'key_name': {'key': 'keyName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AccessKeys, self).__init__(**kwargs) - self.primary_connection_string = None - self.secondary_connection_string = None - self.alias_primary_connection_string = None - self.alias_secondary_connection_string = None - self.primary_key = None - self.secondary_key = None - self.key_name = None - - -class Action(msrest.serialization.Model): - """Represents the filter actions which are allowed for the transformation of a message that have been matched by a filter expression. - - :param sql_expression: SQL expression. e.g. MyProperty='ABC'. - :type sql_expression: str - :param compatibility_level: This property is reserved for future use. An integer value showing - the compatibility level, currently hard-coded to 20. - :type compatibility_level: int - :param requires_preprocessing: Value that indicates whether the rule action requires - preprocessing. - :type requires_preprocessing: bool - """ - - _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(Action, self).__init__(**kwargs) - self.sql_expression = kwargs.get('sql_expression', None) - self.compatibility_level = kwargs.get('compatibility_level', None) - self.requires_preprocessing = kwargs.get('requires_preprocessing', True) - - -class Resource(msrest.serialization.Model): - """The Resource definition for other than namespace. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class ArmDisasterRecovery(Resource): - """Single item in List or Get Alias(Disaster Recovery configuration) operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SystemData - :ivar provisioning_state: Provisioning state of the Alias(Disaster Recovery configuration) - - possible values 'Accepted' or 'Succeeded' or 'Failed'. Possible values include: "Accepted", - "Succeeded", "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.servicebus.v2021_01_01_preview.models.ProvisioningStateDR - :ivar pending_replication_operations_count: Number of entities pending to be replicated. - :vartype pending_replication_operations_count: long - :param partner_namespace: ARM Id of the Primary/Secondary eventhub namespace name, which is - part of GEO DR pairing. - :type partner_namespace: str - :param alternate_name: Primary/Secondary eventhub namespace name, which is part of GEO DR - pairing. - :type alternate_name: str - :ivar role: role of namespace in GEO DR - possible values 'Primary' or 'PrimaryNotReplicating' - or 'Secondary'. Possible values include: "Primary", "PrimaryNotReplicating", "Secondary". - :vartype role: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.RoleDisasterRecovery - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'pending_replication_operations_count': {'readonly': True}, - 'role': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'pending_replication_operations_count': {'key': 'properties.pendingReplicationOperationsCount', 'type': 'long'}, - 'partner_namespace': {'key': 'properties.partnerNamespace', 'type': 'str'}, - 'alternate_name': {'key': 'properties.alternateName', 'type': 'str'}, - 'role': {'key': 'properties.role', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ArmDisasterRecovery, self).__init__(**kwargs) - self.system_data = None - self.provisioning_state = None - self.pending_replication_operations_count = None - self.partner_namespace = kwargs.get('partner_namespace', None) - self.alternate_name = kwargs.get('alternate_name', None) - self.role = None - - -class ArmDisasterRecoveryListResult(msrest.serialization.Model): - """The result of the List Alias(Disaster Recovery configuration) operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: List of Alias(Disaster Recovery configurations). - :type value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.ArmDisasterRecovery] - :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list - of Alias(Disaster Recovery configuration). - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ArmDisasterRecovery]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ArmDisasterRecoveryListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class CheckNameAvailability(msrest.serialization.Model): - """Description of a Check Name availability request properties. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The Name to check the namespace name availability and The namespace name - can contain only letters, numbers, and hyphens. The namespace must start with a letter, and it - must end with a letter or number. - :type name: str - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CheckNameAvailability, self).__init__(**kwargs) - self.name = kwargs['name'] - - -class CheckNameAvailabilityResult(msrest.serialization.Model): - """Description of a Check Name availability request properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar message: The detailed info regarding the reason associated with the namespace. - :vartype message: str - :param name_available: Value indicating namespace is availability, true if the namespace is - available; otherwise, false. - :type name_available: bool - :param reason: The reason for unavailability of a namespace. Possible values include: "None", - "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", - "TooManyNamespaceInCurrentSubscription". - :type reason: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.UnavailableReason - """ - - _validation = { - 'message': {'readonly': True}, - } - - _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CheckNameAvailabilityResult, self).__init__(**kwargs) - self.message = None - self.name_available = kwargs.get('name_available', None) - self.reason = kwargs.get('reason', None) - - -class ConnectionState(msrest.serialization.Model): - """ConnectionState information. - - :param status: Status of the connection. Possible values include: "Pending", "Approved", - "Rejected", "Disconnected". - :type status: str or - ~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateLinkConnectionStatus - :param description: Description of the connection state. - :type description: str - """ - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ConnectionState, self).__init__(**kwargs) - self.status = kwargs.get('status', None) - self.description = kwargs.get('description', None) - - -class CorrelationFilter(msrest.serialization.Model): - """Represents the correlation filter expression. - - :param properties: dictionary object for custom filters. - :type properties: dict[str, str] - :param correlation_id: Identifier of the correlation. - :type correlation_id: str - :param message_id: Identifier of the message. - :type message_id: str - :param to: Address to send to. - :type to: str - :param reply_to: Address of the queue to reply to. - :type reply_to: str - :param label: Application specific label. - :type label: str - :param session_id: Session identifier. - :type session_id: str - :param reply_to_session_id: Session identifier to reply to. - :type reply_to_session_id: str - :param content_type: Content type of the message. - :type content_type: str - :param requires_preprocessing: Value that indicates whether the rule action requires - preprocessing. - :type requires_preprocessing: bool - """ - - _attribute_map = { - 'properties': {'key': 'properties', 'type': '{str}'}, - 'correlation_id': {'key': 'correlationId', 'type': 'str'}, - 'message_id': {'key': 'messageId', 'type': 'str'}, - 'to': {'key': 'to', 'type': 'str'}, - 'reply_to': {'key': 'replyTo', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'session_id': {'key': 'sessionId', 'type': 'str'}, - 'reply_to_session_id': {'key': 'replyToSessionId', 'type': 'str'}, - 'content_type': {'key': 'contentType', 'type': 'str'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(CorrelationFilter, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - 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.requires_preprocessing = kwargs.get('requires_preprocessing', True) - - -class DictionaryValue(msrest.serialization.Model): - """Recognized Dictionary value. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: Principal Id of user assigned identity. - :vartype principal_id: str - :ivar client_id: Client Id of user assigned identity. - :vartype client_id: str - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DictionaryValue, self).__init__(**kwargs) - self.principal_id = None - self.client_id = None - - -class Encryption(msrest.serialization.Model): - """Properties to configure Encryption. - - :param key_vault_properties: Properties of KeyVault. - :type key_vault_properties: - list[~azure.mgmt.servicebus.v2021_01_01_preview.models.KeyVaultProperties] - :param key_source: Enumerates the possible value of keySource for Encryption. The only - acceptable values to pass in are None and "Microsoft.KeyVault". The default value is - "Microsoft.KeyVault". - :type key_source: str - :param require_infrastructure_encryption: Enable Infrastructure Encryption (Double Encryption). - :type require_infrastructure_encryption: bool - """ - - _attribute_map = { - 'key_vault_properties': {'key': 'keyVaultProperties', 'type': '[KeyVaultProperties]'}, - 'key_source': {'key': 'keySource', 'type': 'str'}, - 'require_infrastructure_encryption': {'key': 'requireInfrastructureEncryption', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(Encryption, self).__init__(**kwargs) - self.key_vault_properties = kwargs.get('key_vault_properties', None) - self.key_source = kwargs.get('key_source', "Microsoft.KeyVault") - self.require_infrastructure_encryption = kwargs.get('require_infrastructure_encryption', None) - - -class ErrorAdditionalInfo(msrest.serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: any - """ - - _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorAdditionalInfo, self).__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorResponse(msrest.serialization.Model): - """The resource management error response. - - :param error: The error object. - :type error: ~azure.mgmt.servicebus.v2021_01_01_preview.models.ErrorResponseError - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseError'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class ErrorResponseError(msrest.serialization.Model): - """The error object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.ErrorResponse] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.servicebus.v2021_01_01_preview.models.ErrorAdditionalInfo] - """ - - _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponseError, self).__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class FailoverProperties(msrest.serialization.Model): - """Safe failover is to indicate the service should wait for pending replication to finish before switching to the secondary. - - :param is_safe_failover: Safe failover is to indicate the service should wait for pending - replication to finish before switching to the secondary. - :type is_safe_failover: bool - """ - - _attribute_map = { - 'is_safe_failover': {'key': 'properties.IsSafeFailover', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(FailoverProperties, self).__init__(**kwargs) - self.is_safe_failover = kwargs.get('is_safe_failover', None) - - -class Identity(msrest.serialization.Model): - """Properties to configure User Assigned Identities for Bring your Own Keys. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: ObjectId from the KeyVault. - :vartype principal_id: str - :ivar tenant_id: TenantId from the KeyVault. - :vartype tenant_id: str - :param type: Type of managed service identity. Possible values include: "SystemAssigned", - "UserAssigned", "SystemAssigned, UserAssigned", "None". - :type type: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.ManagedServiceIdentityType - :param user_assigned_identities: Properties for User Assigned Identities. - :type user_assigned_identities: dict[str, - ~azure.mgmt.servicebus.v2021_01_01_preview.models.DictionaryValue] - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{DictionaryValue}'}, - } - - def __init__( - self, - **kwargs - ): - super(Identity, self).__init__(**kwargs) - self.principal_id = None - self.tenant_id = None - self.type = kwargs.get('type', None) - self.user_assigned_identities = kwargs.get('user_assigned_identities', None) - - -class KeyVaultProperties(msrest.serialization.Model): - """Properties to configure keyVault Properties. - - :param key_name: Name of the Key from KeyVault. - :type key_name: str - :param key_vault_uri: Uri of KeyVault. - :type key_vault_uri: str - :param key_version: Version of KeyVault. - :type key_version: str - :param identity: - :type identity: - ~azure.mgmt.servicebus.v2021_01_01_preview.models.UserAssignedIdentityProperties - """ - - _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'key_vault_uri': {'key': 'keyVaultUri', 'type': 'str'}, - 'key_version': {'key': 'keyVersion', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'UserAssignedIdentityProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(KeyVaultProperties, self).__init__(**kwargs) - self.key_name = kwargs.get('key_name', None) - self.key_vault_uri = kwargs.get('key_vault_uri', None) - self.key_version = kwargs.get('key_version', None) - self.identity = kwargs.get('identity', None) - - -class MessageCountDetails(msrest.serialization.Model): - """Message Count Details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar active_message_count: Number of active messages in the queue, topic, or subscription. - :vartype active_message_count: long - :ivar dead_letter_message_count: Number of messages that are dead lettered. - :vartype dead_letter_message_count: long - :ivar scheduled_message_count: Number of scheduled messages. - :vartype scheduled_message_count: long - :ivar transfer_message_count: Number of messages transferred to another queue, topic, or - subscription. - :vartype transfer_message_count: long - :ivar transfer_dead_letter_message_count: Number of messages transferred into dead letters. - :vartype transfer_dead_letter_message_count: long - """ - - _validation = { - 'active_message_count': {'readonly': True}, - 'dead_letter_message_count': {'readonly': True}, - 'scheduled_message_count': {'readonly': True}, - 'transfer_message_count': {'readonly': True}, - 'transfer_dead_letter_message_count': {'readonly': True}, - } - - _attribute_map = { - 'active_message_count': {'key': 'activeMessageCount', 'type': 'long'}, - 'dead_letter_message_count': {'key': 'deadLetterMessageCount', 'type': 'long'}, - 'scheduled_message_count': {'key': 'scheduledMessageCount', 'type': 'long'}, - 'transfer_message_count': {'key': 'transferMessageCount', 'type': 'long'}, - 'transfer_dead_letter_message_count': {'key': 'transferDeadLetterMessageCount', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(MessageCountDetails, self).__init__(**kwargs) - self.active_message_count = None - self.dead_letter_message_count = None - self.scheduled_message_count = None - self.transfer_message_count = None - self.transfer_dead_letter_message_count = None - - -class MigrationConfigListResult(msrest.serialization.Model): - """The result of the List migrationConfigurations operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: List of Migration Configs. - :type value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigProperties] - :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list - of migrationConfigurations. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[MigrationConfigProperties]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MigrationConfigListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class MigrationConfigProperties(Resource): - """Single item in List or Get Migration Config operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SystemData - :ivar provisioning_state: Provisioning state of Migration Configuration. - :vartype provisioning_state: str - :ivar pending_replication_operations_count: Number of entities pending to be replicated. - :vartype pending_replication_operations_count: long - :param target_namespace: Existing premium Namespace ARM Id name which has no entities, will be - used for migration. - :type target_namespace: str - :param post_migration_name: Name to access Standard Namespace after migration. - :type post_migration_name: str - :ivar migration_state: State in which Standard to Premium Migration is, possible values : - Unknown, Reverting, Completing, Initiating, Syncing, Active. - :vartype migration_state: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'pending_replication_operations_count': {'readonly': True}, - 'migration_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'pending_replication_operations_count': {'key': 'properties.pendingReplicationOperationsCount', 'type': 'long'}, - 'target_namespace': {'key': 'properties.targetNamespace', 'type': 'str'}, - 'post_migration_name': {'key': 'properties.postMigrationName', 'type': 'str'}, - 'migration_state': {'key': 'properties.migrationState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MigrationConfigProperties, self).__init__(**kwargs) - self.system_data = None - self.provisioning_state = None - self.pending_replication_operations_count = None - self.target_namespace = kwargs.get('target_namespace', None) - self.post_migration_name = kwargs.get('post_migration_name', None) - self.migration_state = None - - -class NetworkRuleSet(Resource): - """Description of NetworkRuleSet resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SystemData - :param default_action: Default Action for Network Rule Set. Possible values include: "Allow", - "Deny". - :type default_action: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.DefaultAction - :param virtual_network_rules: List VirtualNetwork Rules. - :type virtual_network_rules: - list[~azure.mgmt.servicebus.v2021_01_01_preview.models.NWRuleSetVirtualNetworkRules] - :param ip_rules: List of IpRules. - :type ip_rules: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.NWRuleSetIpRules] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'default_action': {'key': 'properties.defaultAction', 'type': 'str'}, - 'virtual_network_rules': {'key': 'properties.virtualNetworkRules', 'type': '[NWRuleSetVirtualNetworkRules]'}, - 'ip_rules': {'key': 'properties.ipRules', 'type': '[NWRuleSetIpRules]'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkRuleSet, self).__init__(**kwargs) - self.system_data = None - self.default_action = kwargs.get('default_action', None) - self.virtual_network_rules = kwargs.get('virtual_network_rules', None) - self.ip_rules = kwargs.get('ip_rules', None) - - -class NetworkRuleSetListResult(msrest.serialization.Model): - """The response of the List NetworkRuleSet operation. - - :param value: Result of the List NetworkRuleSet operation. - :type value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleSet] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list - of NetworkRuleSet. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[NetworkRuleSet]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkRuleSetListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class NWRuleSetIpRules(msrest.serialization.Model): - """Description of NetWorkRuleSet - IpRules resource. - - :param ip_mask: IP Mask. - :type ip_mask: str - :param action: The IP Filter Action. Possible values include: "Allow". Default value: "Allow". - :type action: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleIPAction - """ - - _attribute_map = { - 'ip_mask': {'key': 'ipMask', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NWRuleSetIpRules, self).__init__(**kwargs) - self.ip_mask = kwargs.get('ip_mask', None) - self.action = kwargs.get('action', "Allow") - - -class NWRuleSetVirtualNetworkRules(msrest.serialization.Model): - """Description of VirtualNetworkRules - NetworkRules resource. - - :param subnet: Subnet properties. - :type subnet: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Subnet - :param ignore_missing_vnet_service_endpoint: Value that indicates whether to ignore missing - VNet Service Endpoint. - :type ignore_missing_vnet_service_endpoint: bool - """ - - _attribute_map = { - 'subnet': {'key': 'subnet', 'type': 'Subnet'}, - 'ignore_missing_vnet_service_endpoint': {'key': 'ignoreMissingVnetServiceEndpoint', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(NWRuleSetVirtualNetworkRules, self).__init__(**kwargs) - self.subnet = kwargs.get('subnet', None) - self.ignore_missing_vnet_service_endpoint = kwargs.get('ignore_missing_vnet_service_endpoint', None) - - -class Operation(msrest.serialization.Model): - """A ServiceBus REST API operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Operation name: {provider}/{resource}/{operation}. - :vartype name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.servicebus.v2021_01_01_preview.models.OperationDisplay - """ - - _validation = { - 'name': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = None - self.display = kwargs.get('display', None) - - -class OperationDisplay(msrest.serialization.Model): - """The object that represents the operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provider: Service provider: Microsoft.ServiceBus. - :vartype provider: str - :ivar resource: Resource on which the operation is performed: Invoice, etc. - :vartype resource: str - :ivar operation: Operation type: Read, write, delete, etc. - :vartype operation: str - """ - - _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, - } - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - - -class OperationListResult(msrest.serialization.Model): - """Result of the request to list ServiceBus operations. It contains a list of operations and a URL link to get the next set of results. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of ServiceBus operations supported by the Microsoft.ServiceBus resource - provider. - :vartype value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.Operation] - :ivar next_link: URL to get the next set of operation list results if there are any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class PrivateEndpoint(msrest.serialization.Model): - """PrivateEndpoint information. - - :param id: The ARM identifier for Private Endpoint. - :type id: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateEndpoint, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - - -class PrivateEndpointConnection(Resource): - """Properties of the PrivateEndpointConnection. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SystemData - :param private_endpoint: The Private Endpoint resource for this Connection. - :type private_endpoint: ~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateEndpoint - :param private_link_service_connection_state: Details about the state of the connection. - :type private_link_service_connection_state: - ~azure.mgmt.servicebus.v2021_01_01_preview.models.ConnectionState - :param provisioning_state: Provisioning state of the Private Endpoint Connection. Possible - values include: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". - :type provisioning_state: str or - ~azure.mgmt.servicebus.v2021_01_01_preview.models.EndPointProvisioningState - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'private_endpoint': {'key': 'properties.privateEndpoint', 'type': 'PrivateEndpoint'}, - 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'ConnectionState'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateEndpointConnection, self).__init__(**kwargs) - self.system_data = None - self.private_endpoint = kwargs.get('private_endpoint', None) - self.private_link_service_connection_state = kwargs.get('private_link_service_connection_state', None) - self.provisioning_state = kwargs.get('provisioning_state', None) - - -class PrivateEndpointConnectionListResult(msrest.serialization.Model): - """Result of the list of all private endpoint connections operation. - - :param value: A collection of private endpoint connection resources. - :type value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateEndpointConnection] - :param next_link: A link for the next page of private endpoint connection resources. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class PrivateLinkResource(msrest.serialization.Model): - """Information of the private link resource. - - :param id: Fully qualified identifier of the resource. - :type id: str - :param name: Name of the resource. - :type name: str - :param type: Type of the resource. - :type type: str - :param group_id: - :type group_id: str - :param required_members: Required Members. - :type required_members: list[str] - :param required_zone_names: Required Zone Names. - :type required_zone_names: list[str] - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'required_members': {'key': 'properties.requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'properties.requiredZoneNames', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateLinkResource, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.name = kwargs.get('name', None) - self.type = kwargs.get('type', None) - self.group_id = kwargs.get('group_id', None) - self.required_members = kwargs.get('required_members', None) - self.required_zone_names = kwargs.get('required_zone_names', None) - - -class PrivateLinkResourcesListResult(msrest.serialization.Model): - """Result of the List private link resources operation. - - :param value: A collection of private link resources. - :type value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateLinkResource] - :param next_link: A link for the next page of private link resources. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateLinkResourcesListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class RegenerateAccessKeyParameters(msrest.serialization.Model): - """Parameters supplied to the Regenerate Authorization Rule operation, specifies which key needs to be reset. - - All required parameters must be populated in order to send to Azure. - - :param key_type: Required. The access key to regenerate. Possible values include: "PrimaryKey", - "SecondaryKey". - :type key_type: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.KeyType - :param key: Optional, if the key value provided, is reset for KeyType value or autogenerate Key - value set for keyType. - :type key: str - """ - - _validation = { - 'key_type': {'required': True}, - } - - _attribute_map = { - 'key_type': {'key': 'keyType', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RegenerateAccessKeyParameters, self).__init__(**kwargs) - self.key_type = kwargs['key_type'] - self.key = kwargs.get('key', None) - - -class ResourceNamespacePatch(Resource): - """The Resource definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceNamespacePatch, self).__init__(**kwargs) - self.location = kwargs.get('location', None) - self.tags = kwargs.get('tags', None) - - -class Rule(Resource): - """Description of Rule Resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SystemData - :param action: Represents the filter actions which are allowed for the transformation of a - message that have been matched by a filter expression. - :type action: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Action - :param filter_type: Filter type that is evaluated against a BrokeredMessage. Possible values - include: "SqlFilter", "CorrelationFilter". - :type filter_type: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.FilterType - :param sql_filter: Properties of sqlFilter. - :type sql_filter: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SqlFilter - :param correlation_filter: Properties of correlationFilter. - :type correlation_filter: ~azure.mgmt.servicebus.v2021_01_01_preview.models.CorrelationFilter - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'action': {'key': 'properties.action', 'type': 'Action'}, - 'filter_type': {'key': 'properties.filterType', 'type': 'str'}, - 'sql_filter': {'key': 'properties.sqlFilter', 'type': 'SqlFilter'}, - 'correlation_filter': {'key': 'properties.correlationFilter', 'type': 'CorrelationFilter'}, - } - - def __init__( - self, - **kwargs - ): - super(Rule, self).__init__(**kwargs) - self.system_data = None - self.action = kwargs.get('action', None) - self.filter_type = kwargs.get('filter_type', None) - self.sql_filter = kwargs.get('sql_filter', None) - self.correlation_filter = kwargs.get('correlation_filter', None) - - -class RuleListResult(msrest.serialization.Model): - """The response of the List rule operation. - - :param value: Result of the List Rules operation. - :type value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.Rule] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list - of rules. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Rule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RuleListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class SBAuthorizationRule(Resource): - """Description of a namespace authorization rule. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SystemData - :param rights: The rights associated with the rule. - :type rights: list[str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessRights] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'rights': {'key': 'properties.rights', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(SBAuthorizationRule, self).__init__(**kwargs) - self.system_data = None - self.rights = kwargs.get('rights', None) - - -class SBAuthorizationRuleListResult(msrest.serialization.Model): - """The response to the List Namespace operation. - - :param value: Result of the List Authorization Rules operation. - :type value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list - of Authorization Rules. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SBAuthorizationRule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SBAuthorizationRuleListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class TrackedResource(Resource): - """The Resource definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: Required. The Geo-location where the resource lives. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(TrackedResource, self).__init__(**kwargs) - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class SBNamespace(TrackedResource): - """Description of a namespace resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: Required. The Geo-location where the resource lives. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param sku: Properties of SKU. - :type sku: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSku - :param identity: Properties of BYOK Identity description. - :type identity: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Identity - :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SystemData - :ivar provisioning_state: Provisioning state of the namespace. - :vartype provisioning_state: str - :ivar status: Status of the namespace. - :vartype status: str - :ivar created_at: The time the namespace was created. - :vartype created_at: ~datetime.datetime - :ivar updated_at: The time the namespace was updated. - :vartype updated_at: ~datetime.datetime - :ivar service_bus_endpoint: Endpoint you can use to perform Service Bus operations. - :vartype service_bus_endpoint: str - :ivar metric_id: Identifier for Azure Insights metrics. - :vartype metric_id: str - :param zone_redundant: Enabling this property creates a Premium Service Bus Namespace in - regions supported availability zones. - :type zone_redundant: bool - :param encryption: Properties of BYOK Encryption description. - :type encryption: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Encryption - :param private_endpoint_connections: List of private endpoint connections. - :type private_endpoint_connections: - list[~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateEndpointConnection] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'service_bus_endpoint': {'readonly': True}, - 'metric_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'sku', 'type': 'SBSku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'service_bus_endpoint': {'key': 'properties.serviceBusEndpoint', 'type': 'str'}, - 'metric_id': {'key': 'properties.metricId', 'type': 'str'}, - 'zone_redundant': {'key': 'properties.zoneRedundant', 'type': 'bool'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - } - - def __init__( - self, - **kwargs - ): - super(SBNamespace, self).__init__(**kwargs) - self.sku = kwargs.get('sku', None) - self.identity = kwargs.get('identity', None) - self.system_data = None - self.provisioning_state = None - self.status = None - self.created_at = None - self.updated_at = None - self.service_bus_endpoint = None - self.metric_id = None - self.zone_redundant = kwargs.get('zone_redundant', None) - self.encryption = kwargs.get('encryption', None) - self.private_endpoint_connections = kwargs.get('private_endpoint_connections', None) - - -class SBNamespaceListResult(msrest.serialization.Model): - """The response of the List Namespace operation. - - :param value: Result of the List Namespace operation. - :type value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list - of Namespaces. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SBNamespace]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SBNamespaceListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class SBNamespaceUpdateParameters(ResourceNamespacePatch): - """Description of a namespace resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param sku: Properties of SKU. - :type sku: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSku - :param identity: Properties of BYOK Identity description. - :type identity: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Identity - :ivar provisioning_state: Provisioning state of the namespace. - :vartype provisioning_state: str - :ivar status: Status of the namespace. - :vartype status: str - :ivar created_at: The time the namespace was created. - :vartype created_at: ~datetime.datetime - :ivar updated_at: The time the namespace was updated. - :vartype updated_at: ~datetime.datetime - :ivar service_bus_endpoint: Endpoint you can use to perform Service Bus operations. - :vartype service_bus_endpoint: str - :ivar metric_id: Identifier for Azure Insights metrics. - :vartype metric_id: str - :param zone_redundant: Enabling this property creates a Premium Service Bus Namespace in - regions supported availability zones. - :type zone_redundant: bool - :param encryption: Properties of BYOK Encryption description. - :type encryption: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Encryption - :param private_endpoint_connections: List of private endpoint connections. - :type private_endpoint_connections: - list[~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateEndpointConnection] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'service_bus_endpoint': {'readonly': True}, - 'metric_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'sku', 'type': 'SBSku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'service_bus_endpoint': {'key': 'properties.serviceBusEndpoint', 'type': 'str'}, - 'metric_id': {'key': 'properties.metricId', 'type': 'str'}, - 'zone_redundant': {'key': 'properties.zoneRedundant', 'type': 'bool'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - } - - def __init__( - self, - **kwargs - ): - super(SBNamespaceUpdateParameters, self).__init__(**kwargs) - self.sku = kwargs.get('sku', None) - self.identity = kwargs.get('identity', None) - self.provisioning_state = None - self.status = None - self.created_at = None - self.updated_at = None - self.service_bus_endpoint = None - self.metric_id = None - self.zone_redundant = kwargs.get('zone_redundant', None) - self.encryption = kwargs.get('encryption', None) - self.private_endpoint_connections = kwargs.get('private_endpoint_connections', None) - - -class SBQueue(Resource): - """Description of queue Resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SystemData - :ivar count_details: Message Count Details. - :vartype count_details: ~azure.mgmt.servicebus.v2021_01_01_preview.models.MessageCountDetails - :ivar created_at: The exact time the message was created. - :vartype created_at: ~datetime.datetime - :ivar updated_at: The exact time the message was 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. - :vartype accessed_at: ~datetime.datetime - :ivar size_in_bytes: The size of the queue, in bytes. - :vartype size_in_bytes: long - :ivar message_count: The number of messages in the queue. - :vartype message_count: long - :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. Default is 1024. - :type max_size_in_megabytes: int - :param requires_duplicate_detection: A value indicating if this queue requires duplicate - detection. - :type requires_duplicate_detection: bool - :param requires_session: A value that indicates whether the queue supports the concept of - sessions. - :type requires_session: bool - :param default_message_time_to_live: ISO 8601 default message timespan to live value. This is - the duration after which the message expires, starting from when the message is sent to Service - Bus. This is the default value used when TimeToLive is not set on a message itself. - :type default_message_time_to_live: ~datetime.timedelta - :param dead_lettering_on_message_expiration: A value that indicates whether this queue has dead - letter support when a message expires. - :type dead_lettering_on_message_expiration: bool - :param duplicate_detection_history_time_window: ISO 8601 timeSpan structure that defines the - duration of the duplicate detection history. The default value is 10 minutes. - :type duplicate_detection_history_time_window: ~datetime.timedelta - :param max_delivery_count: The maximum delivery count. A message is automatically deadlettered - after this number of deliveries. default value is 10. - :type max_delivery_count: int - :param status: Enumerates the possible values for the status of a messaging entity. Possible - values include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", - "Creating", "Deleting", "Renaming", "Unknown". - :type status: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.EntityStatus - :param enable_batched_operations: Value that indicates whether server-side batched operations - are enabled. - :type enable_batched_operations: bool - :param auto_delete_on_idle: ISO 8061 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 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_to: Queue/Topic name to forward the messages. - :type forward_to: str - :param forward_dead_lettered_messages_to: Queue/Topic name to forward the Dead Letter message. - :type forward_dead_lettered_messages_to: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'count_details': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'accessed_at': {'readonly': True}, - 'size_in_bytes': {'readonly': True}, - 'message_count': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'size_in_bytes': {'key': 'properties.sizeInBytes', 'type': 'long'}, - 'message_count': {'key': 'properties.messageCount', 'type': 'long'}, - 'lock_duration': {'key': 'properties.lockDuration', 'type': 'duration'}, - 'max_size_in_megabytes': {'key': 'properties.maxSizeInMegabytes', 'type': 'int'}, - 'requires_duplicate_detection': {'key': 'properties.requiresDuplicateDetection', 'type': 'bool'}, - 'requires_session': {'key': 'properties.requiresSession', 'type': 'bool'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'duration'}, - 'dead_lettering_on_message_expiration': {'key': 'properties.deadLetteringOnMessageExpiration', 'type': 'bool'}, - 'duplicate_detection_history_time_window': {'key': 'properties.duplicateDetectionHistoryTimeWindow', 'type': 'duration'}, - 'max_delivery_count': {'key': 'properties.maxDeliveryCount', 'type': 'int'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'duration'}, - 'enable_partitioning': {'key': 'properties.enablePartitioning', 'type': 'bool'}, - 'enable_express': {'key': 'properties.enableExpress', 'type': 'bool'}, - 'forward_to': {'key': 'properties.forwardTo', 'type': 'str'}, - 'forward_dead_lettered_messages_to': {'key': 'properties.forwardDeadLetteredMessagesTo', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SBQueue, self).__init__(**kwargs) - self.system_data = None - self.count_details = None - self.created_at = None - self.updated_at = None - self.accessed_at = None - self.size_in_bytes = None - self.message_count = None - 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.status = kwargs.get('status', None) - self.enable_batched_operations = kwargs.get('enable_batched_operations', None) - self.auto_delete_on_idle = kwargs.get('auto_delete_on_idle', None) - self.enable_partitioning = kwargs.get('enable_partitioning', None) - self.enable_express = kwargs.get('enable_express', None) - self.forward_to = kwargs.get('forward_to', None) - self.forward_dead_lettered_messages_to = kwargs.get('forward_dead_lettered_messages_to', None) - - -class SBQueueListResult(msrest.serialization.Model): - """The response to the List Queues operation. - - :param value: Result of the List Queues operation. - :type value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBQueue] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list - of queues. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SBQueue]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SBQueueListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class SBSku(msrest.serialization.Model): - """SKU of the namespace. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. Name of this SKU. Possible values include: "Basic", "Standard", - "Premium". - :type name: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.SkuName - :param tier: The billing tier of this particular SKU. Possible values include: "Basic", - "Standard", "Premium". - :type tier: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.SkuTier - :param capacity: The specified messaging units for the tier. For Premium tier, capacity are 1,2 - and 4. - :type capacity: int - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(SBSku, self).__init__(**kwargs) - self.name = kwargs['name'] - self.tier = kwargs.get('tier', None) - self.capacity = kwargs.get('capacity', None) - - -class SBSubscription(Resource): - """Description of subscription resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SystemData - :ivar message_count: Number of messages. - :vartype message_count: long - :ivar created_at: Exact time the message was created. - :vartype created_at: ~datetime.datetime - :ivar accessed_at: Last time there was a receive request to this subscription. - :vartype accessed_at: ~datetime.datetime - :ivar updated_at: The exact time the message was updated. - :vartype updated_at: ~datetime.datetime - :ivar count_details: Message count details. - :vartype count_details: ~azure.mgmt.servicebus.v2021_01_01_preview.models.MessageCountDetails - :param lock_duration: ISO 8061 lock duration timespan for the subscription. The default value - is 1 minute. - :type lock_duration: ~datetime.timedelta - :param requires_session: Value indicating if a subscription supports the concept of sessions. - :type requires_session: bool - :param default_message_time_to_live: ISO 8061 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_filter_evaluation_exceptions: Value that indicates whether a - subscription has dead letter support on filter evaluation exceptions. - :type dead_lettering_on_filter_evaluation_exceptions: bool - :param dead_lettering_on_message_expiration: Value that indicates whether a subscription 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: Number of maximum deliveries. - :type max_delivery_count: int - :param status: Enumerates the possible values for the status of a messaging entity. Possible - values include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", - "Creating", "Deleting", "Renaming", "Unknown". - :type status: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.EntityStatus - :param enable_batched_operations: Value that indicates whether server-side batched operations - are enabled. - :type enable_batched_operations: bool - :param auto_delete_on_idle: ISO 8061 timeSpan idle interval after which the topic is - automatically deleted. The minimum duration is 5 minutes. - :type auto_delete_on_idle: ~datetime.timedelta - :param forward_to: Queue/Topic name to forward the messages. - :type forward_to: str - :param forward_dead_lettered_messages_to: Queue/Topic name to forward the Dead Letter message. - :type forward_dead_lettered_messages_to: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'message_count': {'readonly': True}, - 'created_at': {'readonly': True}, - 'accessed_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'count_details': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'message_count': {'key': 'properties.messageCount', 'type': 'long'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'lock_duration': {'key': 'properties.lockDuration', 'type': 'duration'}, - 'requires_session': {'key': 'properties.requiresSession', 'type': 'bool'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'duration'}, - 'dead_lettering_on_filter_evaluation_exceptions': {'key': 'properties.deadLetteringOnFilterEvaluationExceptions', 'type': 'bool'}, - 'dead_lettering_on_message_expiration': {'key': 'properties.deadLetteringOnMessageExpiration', 'type': 'bool'}, - 'duplicate_detection_history_time_window': {'key': 'properties.duplicateDetectionHistoryTimeWindow', 'type': 'duration'}, - 'max_delivery_count': {'key': 'properties.maxDeliveryCount', 'type': 'int'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'duration'}, - 'forward_to': {'key': 'properties.forwardTo', 'type': 'str'}, - 'forward_dead_lettered_messages_to': {'key': 'properties.forwardDeadLetteredMessagesTo', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SBSubscription, self).__init__(**kwargs) - self.system_data = None - self.message_count = None - self.created_at = None - self.accessed_at = None - self.updated_at = None - self.count_details = None - self.lock_duration = kwargs.get('lock_duration', None) - self.requires_session = kwargs.get('requires_session', None) - self.default_message_time_to_live = kwargs.get('default_message_time_to_live', None) - self.dead_lettering_on_filter_evaluation_exceptions = kwargs.get('dead_lettering_on_filter_evaluation_exceptions', 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.status = kwargs.get('status', None) - self.enable_batched_operations = kwargs.get('enable_batched_operations', None) - self.auto_delete_on_idle = kwargs.get('auto_delete_on_idle', None) - self.forward_to = kwargs.get('forward_to', None) - self.forward_dead_lettered_messages_to = kwargs.get('forward_dead_lettered_messages_to', None) - - -class SBSubscriptionListResult(msrest.serialization.Model): - """The response to the List Subscriptions operation. - - :param value: Result of the List Subscriptions operation. - :type value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSubscription] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list - of subscriptions. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SBSubscription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SBSubscriptionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class SBTopic(Resource): - """Description of topic resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SystemData - :ivar size_in_bytes: Size of the topic, in bytes. - :vartype size_in_bytes: long - :ivar created_at: Exact time the message was created. - :vartype created_at: ~datetime.datetime - :ivar updated_at: The exact time the message was updated. - :vartype updated_at: ~datetime.datetime - :ivar accessed_at: Last time the message was sent, or a request was received, for this topic. - :vartype accessed_at: ~datetime.datetime - :ivar subscription_count: Number of subscriptions. - :vartype subscription_count: int - :ivar count_details: Message count details. - :vartype count_details: ~azure.mgmt.servicebus.v2021_01_01_preview.models.MessageCountDetails - :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: Maximum size of the topic in megabytes, which is the size of the - memory allocated for the topic. Default is 1024. - :type max_size_in_megabytes: int - :param requires_duplicate_detection: Value indicating if this topic requires duplicate - detection. - :type requires_duplicate_detection: bool - :param duplicate_detection_history_time_window: ISO8601 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 status: Enumerates the possible values for the status of a messaging entity. Possible - values include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", - "Creating", "Deleting", "Renaming", "Unknown". - :type status: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.EntityStatus - :param support_ordering: Value that indicates whether the topic supports ordering. - :type support_ordering: bool - :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: Value that indicates whether the topic to be partitioned across - multiple message brokers is enabled. - :type enable_partitioning: bool - :param enable_express: 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 - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'size_in_bytes': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'accessed_at': {'readonly': True}, - 'subscription_count': {'readonly': True}, - 'count_details': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'size_in_bytes': {'key': 'properties.sizeInBytes', 'type': 'long'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'subscription_count': {'key': 'properties.subscriptionCount', 'type': 'int'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'duration'}, - 'max_size_in_megabytes': {'key': 'properties.maxSizeInMegabytes', 'type': 'int'}, - 'requires_duplicate_detection': {'key': 'properties.requiresDuplicateDetection', 'type': 'bool'}, - 'duplicate_detection_history_time_window': {'key': 'properties.duplicateDetectionHistoryTimeWindow', 'type': 'duration'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'support_ordering': {'key': 'properties.supportOrdering', 'type': 'bool'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'duration'}, - 'enable_partitioning': {'key': 'properties.enablePartitioning', 'type': 'bool'}, - 'enable_express': {'key': 'properties.enableExpress', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(SBTopic, self).__init__(**kwargs) - self.system_data = None - self.size_in_bytes = None - self.created_at = None - self.updated_at = None - self.accessed_at = None - self.subscription_count = None - self.count_details = None - self.default_message_time_to_live = kwargs.get('default_message_time_to_live', None) - self.max_size_in_megabytes = kwargs.get('max_size_in_megabytes', None) - self.requires_duplicate_detection = kwargs.get('requires_duplicate_detection', None) - self.duplicate_detection_history_time_window = kwargs.get('duplicate_detection_history_time_window', None) - self.enable_batched_operations = kwargs.get('enable_batched_operations', None) - self.status = kwargs.get('status', None) - self.support_ordering = kwargs.get('support_ordering', None) - self.auto_delete_on_idle = kwargs.get('auto_delete_on_idle', None) - self.enable_partitioning = kwargs.get('enable_partitioning', None) - self.enable_express = kwargs.get('enable_express', None) - - -class SBTopicListResult(msrest.serialization.Model): - """The response to the List Topics operation. - - :param value: Result of the List Topics operation. - :type value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBTopic] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list - of topics. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SBTopic]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SBTopicListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class SqlFilter(msrest.serialization.Model): - """Represents a filter which is a composition of an expression and an action that is executed in the pub/sub pipeline. - - :param sql_expression: The SQL expression. e.g. MyProperty='ABC'. - :type sql_expression: str - :param compatibility_level: This property is reserved for future use. An integer value showing - the compatibility level, currently hard-coded to 20. - :type compatibility_level: int - :param requires_preprocessing: Value that indicates whether the rule action requires - preprocessing. - :type requires_preprocessing: bool - """ - - _validation = { - 'compatibility_level': {'maximum': 20, 'minimum': 20}, - } - - _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(SqlFilter, self).__init__(**kwargs) - self.sql_expression = kwargs.get('sql_expression', None) - self.compatibility_level = kwargs.get('compatibility_level', 20) - self.requires_preprocessing = kwargs.get('requires_preprocessing', True) - - -class SqlRuleAction(Action): - """Represents set of actions written in SQL language-based syntax that is performed against a ServiceBus.Messaging.BrokeredMessage. - - :param sql_expression: SQL expression. e.g. MyProperty='ABC'. - :type sql_expression: str - :param compatibility_level: This property is reserved for future use. An integer value showing - the compatibility level, currently hard-coded to 20. - :type compatibility_level: int - :param requires_preprocessing: Value that indicates whether the rule action requires - preprocessing. - :type requires_preprocessing: bool - """ - - _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(SqlRuleAction, self).__init__(**kwargs) - - -class Subnet(msrest.serialization.Model): - """Properties supplied for Subnet. - - All required parameters must be populated in order to send to Azure. - - :param id: Required. Resource ID of Virtual Network Subnet. - :type id: str - """ - - _validation = { - 'id': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Subnet, self).__init__(**kwargs) - self.id = kwargs['id'] - - -class SystemData(msrest.serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or - ~azure.mgmt.servicebus.v2021_01_01_preview.models.CreatedByType - :param last_modified_at: The type of identity that last modified the resource. - :type last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(SystemData, self).__init__(**kwargs) - self.created_by = kwargs.get('created_by', None) - self.created_by_type = kwargs.get('created_by_type', None) - self.created_at = kwargs.get('created_at', None) - self.last_modified_by = kwargs.get('last_modified_by', None) - self.last_modified_by_type = kwargs.get('last_modified_by_type', None) - self.last_modified_at = kwargs.get('last_modified_at', None) - - -class UserAssignedIdentityProperties(msrest.serialization.Model): - """UserAssignedIdentityProperties. - - :param user_assigned_identity: ARM ID of user Identity selected for encryption. - :type user_assigned_identity: str - """ - - _attribute_map = { - 'user_assigned_identity': {'key': 'userAssignedIdentity', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserAssignedIdentityProperties, self).__init__(**kwargs) - self.user_assigned_identity = kwargs.get('user_assigned_identity', None) diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/models/_models_py3.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/models/_models_py3.py index fb1f26cfa385..e2c0460f4fa6 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/models/_models_py3.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/models/_models_py3.py @@ -66,6 +66,8 @@ def __init__( self, **kwargs ): + """ + """ super(AccessKeys, self).__init__(**kwargs) self.primary_connection_string = None self.secondary_connection_string = None @@ -79,14 +81,14 @@ def __init__( class Action(msrest.serialization.Model): """Represents the filter actions which are allowed for the transformation of a message that have been matched by a filter expression. - :param sql_expression: SQL expression. e.g. MyProperty='ABC'. - :type sql_expression: str - :param compatibility_level: This property is reserved for future use. An integer value showing + :ivar sql_expression: SQL expression. e.g. MyProperty='ABC'. + :vartype sql_expression: str + :ivar compatibility_level: This property is reserved for future use. An integer value showing the compatibility level, currently hard-coded to 20. - :type compatibility_level: int - :param requires_preprocessing: Value that indicates whether the rule action requires + :vartype compatibility_level: int + :ivar requires_preprocessing: Value that indicates whether the rule action requires preprocessing. - :type requires_preprocessing: bool + :vartype requires_preprocessing: bool """ _attribute_map = { @@ -103,6 +105,16 @@ def __init__( requires_preprocessing: Optional[bool] = True, **kwargs ): + """ + :keyword sql_expression: SQL expression. e.g. MyProperty='ABC'. + :paramtype sql_expression: str + :keyword compatibility_level: This property is reserved for future use. An integer value + showing the compatibility level, currently hard-coded to 20. + :paramtype compatibility_level: int + :keyword requires_preprocessing: Value that indicates whether the rule action requires + preprocessing. + :paramtype requires_preprocessing: bool + """ super(Action, self).__init__(**kwargs) self.sql_expression = sql_expression self.compatibility_level = compatibility_level @@ -138,6 +150,8 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -164,12 +178,12 @@ class ArmDisasterRecovery(Resource): ~azure.mgmt.servicebus.v2021_01_01_preview.models.ProvisioningStateDR :ivar pending_replication_operations_count: Number of entities pending to be replicated. :vartype pending_replication_operations_count: long - :param partner_namespace: ARM Id of the Primary/Secondary eventhub namespace name, which is - part of GEO DR pairing. - :type partner_namespace: str - :param alternate_name: Primary/Secondary eventhub namespace name, which is part of GEO DR + :ivar partner_namespace: ARM Id of the Primary/Secondary eventhub namespace name, which is part + of GEO DR pairing. + :vartype partner_namespace: str + :ivar alternate_name: Primary/Secondary eventhub namespace name, which is part of GEO DR pairing. - :type alternate_name: str + :vartype alternate_name: str :ivar role: role of namespace in GEO DR - possible values 'Primary' or 'PrimaryNotReplicating' or 'Secondary'. Possible values include: "Primary", "PrimaryNotReplicating", "Secondary". :vartype role: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.RoleDisasterRecovery @@ -204,6 +218,14 @@ def __init__( alternate_name: Optional[str] = None, **kwargs ): + """ + :keyword partner_namespace: ARM Id of the Primary/Secondary eventhub namespace name, which is + part of GEO DR pairing. + :paramtype partner_namespace: str + :keyword alternate_name: Primary/Secondary eventhub namespace name, which is part of GEO DR + pairing. + :paramtype alternate_name: str + """ super(ArmDisasterRecovery, self).__init__(**kwargs) self.system_data = None self.provisioning_state = None @@ -218,8 +240,8 @@ class ArmDisasterRecoveryListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: List of Alias(Disaster Recovery configurations). - :type value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.ArmDisasterRecovery] + :ivar value: List of Alias(Disaster Recovery configurations). + :vartype value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.ArmDisasterRecovery] :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of Alias(Disaster Recovery configuration). :vartype next_link: str @@ -240,6 +262,10 @@ def __init__( value: Optional[List["ArmDisasterRecovery"]] = None, **kwargs ): + """ + :keyword value: List of Alias(Disaster Recovery configurations). + :paramtype value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.ArmDisasterRecovery] + """ super(ArmDisasterRecoveryListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -250,10 +276,10 @@ class CheckNameAvailability(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The Name to check the namespace name availability and The namespace name + :ivar name: Required. The Name to check the namespace name availability and The namespace name can contain only letters, numbers, and hyphens. The namespace must start with a letter, and it must end with a letter or number. - :type name: str + :vartype name: str """ _validation = { @@ -270,6 +296,12 @@ def __init__( name: str, **kwargs ): + """ + :keyword name: Required. The Name to check the namespace name availability and The namespace + name can contain only letters, numbers, and hyphens. The namespace must start with a letter, + and it must end with a letter or number. + :paramtype name: str + """ super(CheckNameAvailability, self).__init__(**kwargs) self.name = name @@ -281,13 +313,13 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): :ivar message: The detailed info regarding the reason associated with the namespace. :vartype message: str - :param name_available: Value indicating namespace is availability, true if the namespace is + :ivar name_available: Value indicating namespace is availability, true if the namespace is available; otherwise, false. - :type name_available: bool - :param reason: The reason for unavailability of a namespace. Possible values include: "None", + :vartype name_available: bool + :ivar reason: The reason for unavailability of a namespace. Possible values include: "None", "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", "TooManyNamespaceInCurrentSubscription". - :type reason: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.UnavailableReason + :vartype reason: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.UnavailableReason """ _validation = { @@ -307,6 +339,15 @@ def __init__( reason: Optional[Union[str, "UnavailableReason"]] = None, **kwargs ): + """ + :keyword name_available: Value indicating namespace is availability, true if the namespace is + available; otherwise, false. + :paramtype name_available: bool + :keyword reason: The reason for unavailability of a namespace. Possible values include: "None", + "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", + "TooManyNamespaceInCurrentSubscription". + :paramtype reason: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.UnavailableReason + """ super(CheckNameAvailabilityResult, self).__init__(**kwargs) self.message = None self.name_available = name_available @@ -316,12 +357,12 @@ def __init__( class ConnectionState(msrest.serialization.Model): """ConnectionState information. - :param status: Status of the connection. Possible values include: "Pending", "Approved", + :ivar status: Status of the connection. Possible values include: "Pending", "Approved", "Rejected", "Disconnected". - :type status: str or + :vartype status: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateLinkConnectionStatus - :param description: Description of the connection state. - :type description: str + :ivar description: Description of the connection state. + :vartype description: str """ _attribute_map = { @@ -336,6 +377,14 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword status: Status of the connection. Possible values include: "Pending", "Approved", + "Rejected", "Disconnected". + :paramtype status: str or + ~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateLinkConnectionStatus + :keyword description: Description of the connection state. + :paramtype description: str + """ super(ConnectionState, self).__init__(**kwargs) self.status = status self.description = description @@ -344,27 +393,27 @@ def __init__( class CorrelationFilter(msrest.serialization.Model): """Represents the correlation filter expression. - :param properties: dictionary object for custom filters. - :type properties: dict[str, str] - :param correlation_id: Identifier of the correlation. - :type correlation_id: str - :param message_id: Identifier of the message. - :type message_id: str - :param to: Address to send to. - :type to: str - :param reply_to: Address of the queue to reply to. - :type reply_to: str - :param label: Application specific label. - :type label: str - :param session_id: Session identifier. - :type session_id: str - :param reply_to_session_id: Session identifier to reply to. - :type reply_to_session_id: str - :param content_type: Content type of the message. - :type content_type: str - :param requires_preprocessing: Value that indicates whether the rule action requires + :ivar properties: dictionary object for custom filters. + :vartype properties: dict[str, str] + :ivar correlation_id: Identifier of the correlation. + :vartype correlation_id: str + :ivar message_id: Identifier of the message. + :vartype message_id: str + :ivar to: Address to send to. + :vartype to: str + :ivar reply_to: Address of the queue to reply to. + :vartype reply_to: str + :ivar label: Application specific label. + :vartype label: str + :ivar session_id: Session identifier. + :vartype session_id: str + :ivar reply_to_session_id: Session identifier to reply to. + :vartype reply_to_session_id: str + :ivar content_type: Content type of the message. + :vartype content_type: str + :ivar requires_preprocessing: Value that indicates whether the rule action requires preprocessing. - :type requires_preprocessing: bool + :vartype requires_preprocessing: bool """ _attribute_map = { @@ -395,6 +444,29 @@ def __init__( requires_preprocessing: Optional[bool] = True, **kwargs ): + """ + :keyword properties: dictionary object for custom filters. + :paramtype properties: dict[str, str] + :keyword correlation_id: Identifier of the correlation. + :paramtype correlation_id: str + :keyword message_id: Identifier of the message. + :paramtype message_id: str + :keyword to: Address to send to. + :paramtype to: str + :keyword reply_to: Address of the queue to reply to. + :paramtype reply_to: str + :keyword label: Application specific label. + :paramtype label: str + :keyword session_id: Session identifier. + :paramtype session_id: str + :keyword reply_to_session_id: Session identifier to reply to. + :paramtype reply_to_session_id: str + :keyword content_type: Content type of the message. + :paramtype content_type: str + :keyword requires_preprocessing: Value that indicates whether the rule action requires + preprocessing. + :paramtype requires_preprocessing: bool + """ super(CorrelationFilter, self).__init__(**kwargs) self.properties = properties self.correlation_id = correlation_id @@ -433,6 +505,8 @@ def __init__( self, **kwargs ): + """ + """ super(DictionaryValue, self).__init__(**kwargs) self.principal_id = None self.client_id = None @@ -441,15 +515,15 @@ def __init__( class Encryption(msrest.serialization.Model): """Properties to configure Encryption. - :param key_vault_properties: Properties of KeyVault. - :type key_vault_properties: + :ivar key_vault_properties: Properties of KeyVault. + :vartype key_vault_properties: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.KeyVaultProperties] - :param key_source: Enumerates the possible value of keySource for Encryption. The only + :ivar key_source: Enumerates the possible value of keySource for Encryption. The only acceptable values to pass in are None and "Microsoft.KeyVault". The default value is "Microsoft.KeyVault". - :type key_source: str - :param require_infrastructure_encryption: Enable Infrastructure Encryption (Double Encryption). - :type require_infrastructure_encryption: bool + :vartype key_source: str + :ivar require_infrastructure_encryption: Enable Infrastructure Encryption (Double Encryption). + :vartype require_infrastructure_encryption: bool """ _attribute_map = { @@ -466,6 +540,18 @@ def __init__( require_infrastructure_encryption: Optional[bool] = None, **kwargs ): + """ + :keyword key_vault_properties: Properties of KeyVault. + :paramtype key_vault_properties: + list[~azure.mgmt.servicebus.v2021_01_01_preview.models.KeyVaultProperties] + :keyword key_source: Enumerates the possible value of keySource for Encryption. The only + acceptable values to pass in are None and "Microsoft.KeyVault". The default value is + "Microsoft.KeyVault". + :paramtype key_source: str + :keyword require_infrastructure_encryption: Enable Infrastructure Encryption (Double + Encryption). + :paramtype require_infrastructure_encryption: bool + """ super(Encryption, self).__init__(**kwargs) self.key_vault_properties = key_vault_properties self.key_source = key_source @@ -497,6 +583,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -505,8 +593,8 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """The resource management error response. - :param error: The error object. - :type error: ~azure.mgmt.servicebus.v2021_01_01_preview.models.ErrorResponseError + :ivar error: The error object. + :vartype error: ~azure.mgmt.servicebus.v2021_01_01_preview.models.ErrorResponseError """ _attribute_map = { @@ -519,6 +607,10 @@ def __init__( error: Optional["ErrorResponseError"] = None, **kwargs ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.servicebus.v2021_01_01_preview.models.ErrorResponseError + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -561,6 +653,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponseError, self).__init__(**kwargs) self.code = None self.message = None @@ -572,9 +666,9 @@ def __init__( class FailoverProperties(msrest.serialization.Model): """Safe failover is to indicate the service should wait for pending replication to finish before switching to the secondary. - :param is_safe_failover: Safe failover is to indicate the service should wait for pending + :ivar is_safe_failover: Safe failover is to indicate the service should wait for pending replication to finish before switching to the secondary. - :type is_safe_failover: bool + :vartype is_safe_failover: bool """ _attribute_map = { @@ -587,6 +681,11 @@ def __init__( is_safe_failover: Optional[bool] = None, **kwargs ): + """ + :keyword is_safe_failover: Safe failover is to indicate the service should wait for pending + replication to finish before switching to the secondary. + :paramtype is_safe_failover: bool + """ super(FailoverProperties, self).__init__(**kwargs) self.is_safe_failover = is_safe_failover @@ -600,11 +699,12 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: TenantId from the KeyVault. :vartype tenant_id: str - :param type: Type of managed service identity. Possible values include: "SystemAssigned", + :ivar type: Type of managed service identity. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". - :type type: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.ManagedServiceIdentityType - :param user_assigned_identities: Properties for User Assigned Identities. - :type user_assigned_identities: dict[str, + :vartype type: str or + ~azure.mgmt.servicebus.v2021_01_01_preview.models.ManagedServiceIdentityType + :ivar user_assigned_identities: Properties for User Assigned Identities. + :vartype user_assigned_identities: dict[str, ~azure.mgmt.servicebus.v2021_01_01_preview.models.DictionaryValue] """ @@ -627,6 +727,15 @@ def __init__( user_assigned_identities: Optional[Dict[str, "DictionaryValue"]] = None, **kwargs ): + """ + :keyword type: Type of managed service identity. Possible values include: "SystemAssigned", + "UserAssigned", "SystemAssigned, UserAssigned", "None". + :paramtype type: str or + ~azure.mgmt.servicebus.v2021_01_01_preview.models.ManagedServiceIdentityType + :keyword user_assigned_identities: Properties for User Assigned Identities. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.servicebus.v2021_01_01_preview.models.DictionaryValue] + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -637,14 +746,14 @@ def __init__( class KeyVaultProperties(msrest.serialization.Model): """Properties to configure keyVault Properties. - :param key_name: Name of the Key from KeyVault. - :type key_name: str - :param key_vault_uri: Uri of KeyVault. - :type key_vault_uri: str - :param key_version: Version of KeyVault. - :type key_version: str - :param identity: - :type identity: + :ivar key_name: Name of the Key from KeyVault. + :vartype key_name: str + :ivar key_vault_uri: Uri of KeyVault. + :vartype key_vault_uri: str + :ivar key_version: Version of KeyVault. + :vartype key_version: str + :ivar identity: + :vartype identity: ~azure.mgmt.servicebus.v2021_01_01_preview.models.UserAssignedIdentityProperties """ @@ -664,6 +773,17 @@ def __init__( identity: Optional["UserAssignedIdentityProperties"] = None, **kwargs ): + """ + :keyword key_name: Name of the Key from KeyVault. + :paramtype key_name: str + :keyword key_vault_uri: Uri of KeyVault. + :paramtype key_vault_uri: str + :keyword key_version: Version of KeyVault. + :paramtype key_version: str + :keyword identity: + :paramtype identity: + ~azure.mgmt.servicebus.v2021_01_01_preview.models.UserAssignedIdentityProperties + """ super(KeyVaultProperties, self).__init__(**kwargs) self.key_name = key_name self.key_vault_uri = key_vault_uri @@ -709,6 +829,8 @@ def __init__( self, **kwargs ): + """ + """ super(MessageCountDetails, self).__init__(**kwargs) self.active_message_count = None self.dead_letter_message_count = None @@ -722,8 +844,9 @@ class MigrationConfigListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: List of Migration Configs. - :type value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigProperties] + :ivar value: List of Migration Configs. + :vartype value: + list[~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigProperties] :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of migrationConfigurations. :vartype next_link: str @@ -744,6 +867,11 @@ def __init__( value: Optional[List["MigrationConfigProperties"]] = None, **kwargs ): + """ + :keyword value: List of Migration Configs. + :paramtype value: + list[~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigProperties] + """ super(MigrationConfigListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -766,11 +894,11 @@ class MigrationConfigProperties(Resource): :vartype provisioning_state: str :ivar pending_replication_operations_count: Number of entities pending to be replicated. :vartype pending_replication_operations_count: long - :param target_namespace: Existing premium Namespace ARM Id name which has no entities, will be + :ivar target_namespace: Existing premium Namespace ARM Id name which has no entities, will be used for migration. - :type target_namespace: str - :param post_migration_name: Name to access Standard Namespace after migration. - :type post_migration_name: str + :vartype target_namespace: str + :ivar post_migration_name: Name to access Standard Namespace after migration. + :vartype post_migration_name: str :ivar migration_state: State in which Standard to Premium Migration is, possible values : Unknown, Reverting, Completing, Initiating, Syncing, Active. :vartype migration_state: str @@ -805,6 +933,13 @@ def __init__( post_migration_name: Optional[str] = None, **kwargs ): + """ + :keyword target_namespace: Existing premium Namespace ARM Id name which has no entities, will + be used for migration. + :paramtype target_namespace: str + :keyword post_migration_name: Name to access Standard Namespace after migration. + :paramtype post_migration_name: str + """ super(MigrationConfigProperties, self).__init__(**kwargs) self.system_data = None self.provisioning_state = None @@ -827,14 +962,14 @@ class NetworkRuleSet(Resource): :vartype type: str :ivar system_data: The system meta data relating to this resource. :vartype system_data: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SystemData - :param default_action: Default Action for Network Rule Set. Possible values include: "Allow", + :ivar default_action: Default Action for Network Rule Set. Possible values include: "Allow", "Deny". - :type default_action: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.DefaultAction - :param virtual_network_rules: List VirtualNetwork Rules. - :type virtual_network_rules: + :vartype default_action: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.DefaultAction + :ivar virtual_network_rules: List VirtualNetwork Rules. + :vartype virtual_network_rules: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.NWRuleSetVirtualNetworkRules] - :param ip_rules: List of IpRules. - :type ip_rules: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.NWRuleSetIpRules] + :ivar ip_rules: List of IpRules. + :vartype ip_rules: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.NWRuleSetIpRules] """ _validation = { @@ -862,6 +997,17 @@ def __init__( ip_rules: Optional[List["NWRuleSetIpRules"]] = None, **kwargs ): + """ + :keyword default_action: Default Action for Network Rule Set. Possible values include: "Allow", + "Deny". + :paramtype default_action: str or + ~azure.mgmt.servicebus.v2021_01_01_preview.models.DefaultAction + :keyword virtual_network_rules: List VirtualNetwork Rules. + :paramtype virtual_network_rules: + list[~azure.mgmt.servicebus.v2021_01_01_preview.models.NWRuleSetVirtualNetworkRules] + :keyword ip_rules: List of IpRules. + :paramtype ip_rules: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.NWRuleSetIpRules] + """ super(NetworkRuleSet, self).__init__(**kwargs) self.system_data = None self.default_action = default_action @@ -872,11 +1018,11 @@ def __init__( class NetworkRuleSetListResult(msrest.serialization.Model): """The response of the List NetworkRuleSet operation. - :param value: Result of the List NetworkRuleSet operation. - :type value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleSet] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list + :ivar value: Result of the List NetworkRuleSet operation. + :vartype value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleSet] + :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of NetworkRuleSet. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -891,6 +1037,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of the List NetworkRuleSet operation. + :paramtype value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleSet] + :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete + list of NetworkRuleSet. + :paramtype next_link: str + """ super(NetworkRuleSetListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -899,10 +1052,10 @@ def __init__( class NWRuleSetIpRules(msrest.serialization.Model): """Description of NetWorkRuleSet - IpRules resource. - :param ip_mask: IP Mask. - :type ip_mask: str - :param action: The IP Filter Action. Possible values include: "Allow". Default value: "Allow". - :type action: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleIPAction + :ivar ip_mask: IP Mask. + :vartype ip_mask: str + :ivar action: The IP Filter Action. Possible values include: "Allow". Default value: "Allow". + :vartype action: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleIPAction """ _attribute_map = { @@ -917,6 +1070,13 @@ def __init__( action: Optional[Union[str, "NetworkRuleIPAction"]] = "Allow", **kwargs ): + """ + :keyword ip_mask: IP Mask. + :paramtype ip_mask: str + :keyword action: The IP Filter Action. Possible values include: "Allow". Default value: + "Allow". + :paramtype action: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleIPAction + """ super(NWRuleSetIpRules, self).__init__(**kwargs) self.ip_mask = ip_mask self.action = action @@ -925,11 +1085,11 @@ def __init__( class NWRuleSetVirtualNetworkRules(msrest.serialization.Model): """Description of VirtualNetworkRules - NetworkRules resource. - :param subnet: Subnet properties. - :type subnet: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Subnet - :param ignore_missing_vnet_service_endpoint: Value that indicates whether to ignore missing - VNet Service Endpoint. - :type ignore_missing_vnet_service_endpoint: bool + :ivar subnet: Subnet properties. + :vartype subnet: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Subnet + :ivar ignore_missing_vnet_service_endpoint: Value that indicates whether to ignore missing VNet + Service Endpoint. + :vartype ignore_missing_vnet_service_endpoint: bool """ _attribute_map = { @@ -944,6 +1104,13 @@ def __init__( ignore_missing_vnet_service_endpoint: Optional[bool] = None, **kwargs ): + """ + :keyword subnet: Subnet properties. + :paramtype subnet: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Subnet + :keyword ignore_missing_vnet_service_endpoint: Value that indicates whether to ignore missing + VNet Service Endpoint. + :paramtype ignore_missing_vnet_service_endpoint: bool + """ super(NWRuleSetVirtualNetworkRules, self).__init__(**kwargs) self.subnet = subnet self.ignore_missing_vnet_service_endpoint = ignore_missing_vnet_service_endpoint @@ -956,8 +1123,8 @@ class Operation(msrest.serialization.Model): :ivar name: Operation name: {provider}/{resource}/{operation}. :vartype name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.servicebus.v2021_01_01_preview.models.OperationDisplay + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.servicebus.v2021_01_01_preview.models.OperationDisplay """ _validation = { @@ -975,6 +1142,10 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.servicebus.v2021_01_01_preview.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = None self.display = display @@ -1009,6 +1180,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = None self.resource = None @@ -1041,6 +1214,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -1049,8 +1224,8 @@ def __init__( class PrivateEndpoint(msrest.serialization.Model): """PrivateEndpoint information. - :param id: The ARM identifier for Private Endpoint. - :type id: str + :ivar id: The ARM identifier for Private Endpoint. + :vartype id: str """ _attribute_map = { @@ -1063,6 +1238,10 @@ def __init__( id: Optional[str] = None, **kwargs ): + """ + :keyword id: The ARM identifier for Private Endpoint. + :paramtype id: str + """ super(PrivateEndpoint, self).__init__(**kwargs) self.id = id @@ -1080,14 +1259,14 @@ class PrivateEndpointConnection(Resource): :vartype type: str :ivar system_data: The system meta data relating to this resource. :vartype system_data: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SystemData - :param private_endpoint: The Private Endpoint resource for this Connection. - :type private_endpoint: ~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateEndpoint - :param private_link_service_connection_state: Details about the state of the connection. - :type private_link_service_connection_state: + :ivar private_endpoint: The Private Endpoint resource for this Connection. + :vartype private_endpoint: ~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateEndpoint + :ivar private_link_service_connection_state: Details about the state of the connection. + :vartype private_link_service_connection_state: ~azure.mgmt.servicebus.v2021_01_01_preview.models.ConnectionState - :param provisioning_state: Provisioning state of the Private Endpoint Connection. Possible + :ivar provisioning_state: Provisioning state of the Private Endpoint Connection. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". - :type provisioning_state: str or + :vartype provisioning_state: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.EndPointProvisioningState """ @@ -1116,6 +1295,17 @@ def __init__( provisioning_state: Optional[Union[str, "EndPointProvisioningState"]] = None, **kwargs ): + """ + :keyword private_endpoint: The Private Endpoint resource for this Connection. + :paramtype private_endpoint: ~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateEndpoint + :keyword private_link_service_connection_state: Details about the state of the connection. + :paramtype private_link_service_connection_state: + ~azure.mgmt.servicebus.v2021_01_01_preview.models.ConnectionState + :keyword provisioning_state: Provisioning state of the Private Endpoint Connection. Possible + values include: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". + :paramtype provisioning_state: str or + ~azure.mgmt.servicebus.v2021_01_01_preview.models.EndPointProvisioningState + """ super(PrivateEndpointConnection, self).__init__(**kwargs) self.system_data = None self.private_endpoint = private_endpoint @@ -1126,10 +1316,11 @@ def __init__( class PrivateEndpointConnectionListResult(msrest.serialization.Model): """Result of the list of all private endpoint connections operation. - :param value: A collection of private endpoint connection resources. - :type value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateEndpointConnection] - :param next_link: A link for the next page of private endpoint connection resources. - :type next_link: str + :ivar value: A collection of private endpoint connection resources. + :vartype value: + list[~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateEndpointConnection] + :ivar next_link: A link for the next page of private endpoint connection resources. + :vartype next_link: str """ _attribute_map = { @@ -1144,6 +1335,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: A collection of private endpoint connection resources. + :paramtype value: + list[~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateEndpointConnection] + :keyword next_link: A link for the next page of private endpoint connection resources. + :paramtype next_link: str + """ super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1152,18 +1350,18 @@ def __init__( class PrivateLinkResource(msrest.serialization.Model): """Information of the private link resource. - :param id: Fully qualified identifier of the resource. - :type id: str - :param name: Name of the resource. - :type name: str - :param type: Type of the resource. - :type type: str - :param group_id: - :type group_id: str - :param required_members: Required Members. - :type required_members: list[str] - :param required_zone_names: Required Zone Names. - :type required_zone_names: list[str] + :ivar id: Fully qualified identifier of the resource. + :vartype id: str + :ivar name: Name of the resource. + :vartype name: str + :ivar type: Type of the resource. + :vartype type: str + :ivar group_id: + :vartype group_id: str + :ivar required_members: Required Members. + :vartype required_members: list[str] + :ivar required_zone_names: Required Zone Names. + :vartype required_zone_names: list[str] """ _attribute_map = { @@ -1186,6 +1384,20 @@ def __init__( required_zone_names: Optional[List[str]] = None, **kwargs ): + """ + :keyword id: Fully qualified identifier of the resource. + :paramtype id: str + :keyword name: Name of the resource. + :paramtype name: str + :keyword type: Type of the resource. + :paramtype type: str + :keyword group_id: + :paramtype group_id: str + :keyword required_members: Required Members. + :paramtype required_members: list[str] + :keyword required_zone_names: Required Zone Names. + :paramtype required_zone_names: list[str] + """ super(PrivateLinkResource, self).__init__(**kwargs) self.id = id self.name = name @@ -1198,10 +1410,10 @@ def __init__( class PrivateLinkResourcesListResult(msrest.serialization.Model): """Result of the List private link resources operation. - :param value: A collection of private link resources. - :type value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateLinkResource] - :param next_link: A link for the next page of private link resources. - :type next_link: str + :ivar value: A collection of private link resources. + :vartype value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateLinkResource] + :ivar next_link: A link for the next page of private link resources. + :vartype next_link: str """ _attribute_map = { @@ -1216,6 +1428,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: A collection of private link resources. + :paramtype value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateLinkResource] + :keyword next_link: A link for the next page of private link resources. + :paramtype next_link: str + """ super(PrivateLinkResourcesListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1226,12 +1444,12 @@ class RegenerateAccessKeyParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param key_type: Required. The access key to regenerate. Possible values include: "PrimaryKey", + :ivar key_type: Required. The access key to regenerate. Possible values include: "PrimaryKey", "SecondaryKey". - :type key_type: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.KeyType - :param key: Optional, if the key value provided, is reset for KeyType value or autogenerate Key + :vartype key_type: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.KeyType + :ivar key: Optional, if the key value provided, is reset for KeyType value or autogenerate Key value set for keyType. - :type key: str + :vartype key: str """ _validation = { @@ -1250,6 +1468,14 @@ def __init__( key: Optional[str] = None, **kwargs ): + """ + :keyword key_type: Required. The access key to regenerate. Possible values include: + "PrimaryKey", "SecondaryKey". + :paramtype key_type: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.KeyType + :keyword key: Optional, if the key value provided, is reset for KeyType value or autogenerate + Key value set for keyType. + :paramtype key: str + """ super(RegenerateAccessKeyParameters, self).__init__(**kwargs) self.key_type = key_type self.key = key @@ -1266,10 +1492,10 @@ class ResourceNamespacePatch(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -1293,6 +1519,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(ResourceNamespacePatch, self).__init__(**kwargs) self.location = location self.tags = tags @@ -1311,16 +1543,17 @@ class Rule(Resource): :vartype type: str :ivar system_data: The system meta data relating to this resource. :vartype system_data: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SystemData - :param action: Represents the filter actions which are allowed for the transformation of a + :ivar action: Represents the filter actions which are allowed for the transformation of a message that have been matched by a filter expression. - :type action: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Action - :param filter_type: Filter type that is evaluated against a BrokeredMessage. Possible values + :vartype action: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Action + :ivar filter_type: Filter type that is evaluated against a BrokeredMessage. Possible values include: "SqlFilter", "CorrelationFilter". - :type filter_type: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.FilterType - :param sql_filter: Properties of sqlFilter. - :type sql_filter: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SqlFilter - :param correlation_filter: Properties of correlationFilter. - :type correlation_filter: ~azure.mgmt.servicebus.v2021_01_01_preview.models.CorrelationFilter + :vartype filter_type: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.FilterType + :ivar sql_filter: Properties of sqlFilter. + :vartype sql_filter: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SqlFilter + :ivar correlation_filter: Properties of correlationFilter. + :vartype correlation_filter: + ~azure.mgmt.servicebus.v2021_01_01_preview.models.CorrelationFilter """ _validation = { @@ -1350,6 +1583,19 @@ def __init__( correlation_filter: Optional["CorrelationFilter"] = None, **kwargs ): + """ + :keyword action: Represents the filter actions which are allowed for the transformation of a + message that have been matched by a filter expression. + :paramtype action: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Action + :keyword filter_type: Filter type that is evaluated against a BrokeredMessage. Possible values + include: "SqlFilter", "CorrelationFilter". + :paramtype filter_type: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.FilterType + :keyword sql_filter: Properties of sqlFilter. + :paramtype sql_filter: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SqlFilter + :keyword correlation_filter: Properties of correlationFilter. + :paramtype correlation_filter: + ~azure.mgmt.servicebus.v2021_01_01_preview.models.CorrelationFilter + """ super(Rule, self).__init__(**kwargs) self.system_data = None self.action = action @@ -1361,11 +1607,11 @@ def __init__( class RuleListResult(msrest.serialization.Model): """The response of the List rule operation. - :param value: Result of the List Rules operation. - :type value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.Rule] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list + :ivar value: Result of the List Rules operation. + :vartype value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.Rule] + :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of rules. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -1380,6 +1626,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of the List Rules operation. + :paramtype value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.Rule] + :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete + list of rules. + :paramtype next_link: str + """ super(RuleListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1398,8 +1651,8 @@ class SBAuthorizationRule(Resource): :vartype type: str :ivar system_data: The system meta data relating to this resource. :vartype system_data: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SystemData - :param rights: The rights associated with the rule. - :type rights: list[str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessRights] + :ivar rights: The rights associated with the rule. + :vartype rights: list[str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessRights] """ _validation = { @@ -1423,6 +1676,10 @@ def __init__( rights: Optional[List[Union[str, "AccessRights"]]] = None, **kwargs ): + """ + :keyword rights: The rights associated with the rule. + :paramtype rights: list[str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessRights] + """ super(SBAuthorizationRule, self).__init__(**kwargs) self.system_data = None self.rights = rights @@ -1431,11 +1688,11 @@ def __init__( class SBAuthorizationRuleListResult(msrest.serialization.Model): """The response to the List Namespace operation. - :param value: Result of the List Authorization Rules operation. - :type value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list + :ivar value: Result of the List Authorization Rules operation. + :vartype value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule] + :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of Authorization Rules. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -1450,6 +1707,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of the List Authorization Rules operation. + :paramtype value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule] + :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete + list of Authorization Rules. + :paramtype next_link: str + """ super(SBAuthorizationRuleListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1468,10 +1732,10 @@ class TrackedResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Required. The Geo-location where the resource lives. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Required. The Geo-location where the resource lives. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -1496,6 +1760,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. The Geo-location where the resource lives. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(TrackedResource, self).__init__(**kwargs) self.location = location self.tags = tags @@ -1514,14 +1784,14 @@ class SBNamespace(TrackedResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Required. The Geo-location where the resource lives. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param sku: Properties of SKU. - :type sku: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSku - :param identity: Properties of BYOK Identity description. - :type identity: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Identity + :ivar location: Required. The Geo-location where the resource lives. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar sku: Properties of SKU. + :vartype sku: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSku + :ivar identity: Properties of BYOK Identity description. + :vartype identity: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Identity :ivar system_data: The system meta data relating to this resource. :vartype system_data: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SystemData :ivar provisioning_state: Provisioning state of the namespace. @@ -1536,13 +1806,13 @@ class SBNamespace(TrackedResource): :vartype service_bus_endpoint: str :ivar metric_id: Identifier for Azure Insights metrics. :vartype metric_id: str - :param zone_redundant: Enabling this property creates a Premium Service Bus Namespace in - regions supported availability zones. - :type zone_redundant: bool - :param encryption: Properties of BYOK Encryption description. - :type encryption: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Encryption - :param private_endpoint_connections: List of private endpoint connections. - :type private_endpoint_connections: + :ivar zone_redundant: Enabling this property creates a Premium Service Bus Namespace in regions + supported availability zones. + :vartype zone_redundant: bool + :ivar encryption: Properties of BYOK Encryption description. + :vartype encryption: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Encryption + :ivar private_endpoint_connections: List of private endpoint connections. + :vartype private_endpoint_connections: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateEndpointConnection] """ @@ -1592,6 +1862,24 @@ def __init__( private_endpoint_connections: Optional[List["PrivateEndpointConnection"]] = None, **kwargs ): + """ + :keyword location: Required. The Geo-location where the resource lives. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword sku: Properties of SKU. + :paramtype sku: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSku + :keyword identity: Properties of BYOK Identity description. + :paramtype identity: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Identity + :keyword zone_redundant: Enabling this property creates a Premium Service Bus Namespace in + regions supported availability zones. + :paramtype zone_redundant: bool + :keyword encryption: Properties of BYOK Encryption description. + :paramtype encryption: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Encryption + :keyword private_endpoint_connections: List of private endpoint connections. + :paramtype private_endpoint_connections: + list[~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateEndpointConnection] + """ super(SBNamespace, self).__init__(location=location, tags=tags, **kwargs) self.sku = sku self.identity = identity @@ -1610,11 +1898,11 @@ def __init__( class SBNamespaceListResult(msrest.serialization.Model): """The response of the List Namespace operation. - :param value: Result of the List Namespace operation. - :type value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list + :ivar value: Result of the List Namespace operation. + :vartype value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace] + :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of Namespaces. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -1629,6 +1917,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of the List Namespace operation. + :paramtype value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace] + :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete + list of Namespaces. + :paramtype next_link: str + """ super(SBNamespaceListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1645,14 +1940,14 @@ class SBNamespaceUpdateParameters(ResourceNamespacePatch): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param sku: Properties of SKU. - :type sku: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSku - :param identity: Properties of BYOK Identity description. - :type identity: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar sku: Properties of SKU. + :vartype sku: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSku + :ivar identity: Properties of BYOK Identity description. + :vartype identity: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Identity :ivar provisioning_state: Provisioning state of the namespace. :vartype provisioning_state: str :ivar status: Status of the namespace. @@ -1665,13 +1960,13 @@ class SBNamespaceUpdateParameters(ResourceNamespacePatch): :vartype service_bus_endpoint: str :ivar metric_id: Identifier for Azure Insights metrics. :vartype metric_id: str - :param zone_redundant: Enabling this property creates a Premium Service Bus Namespace in - regions supported availability zones. - :type zone_redundant: bool - :param encryption: Properties of BYOK Encryption description. - :type encryption: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Encryption - :param private_endpoint_connections: List of private endpoint connections. - :type private_endpoint_connections: + :ivar zone_redundant: Enabling this property creates a Premium Service Bus Namespace in regions + supported availability zones. + :vartype zone_redundant: bool + :ivar encryption: Properties of BYOK Encryption description. + :vartype encryption: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Encryption + :ivar private_endpoint_connections: List of private endpoint connections. + :vartype private_endpoint_connections: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateEndpointConnection] """ @@ -1718,6 +2013,24 @@ def __init__( private_endpoint_connections: Optional[List["PrivateEndpointConnection"]] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword sku: Properties of SKU. + :paramtype sku: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSku + :keyword identity: Properties of BYOK Identity description. + :paramtype identity: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Identity + :keyword zone_redundant: Enabling this property creates a Premium Service Bus Namespace in + regions supported availability zones. + :paramtype zone_redundant: bool + :keyword encryption: Properties of BYOK Encryption description. + :paramtype encryption: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Encryption + :keyword private_endpoint_connections: List of private endpoint connections. + :paramtype private_endpoint_connections: + list[~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateEndpointConnection] + """ super(SBNamespaceUpdateParameters, self).__init__(location=location, tags=tags, **kwargs) self.sku = sku self.identity = identity @@ -1758,52 +2071,52 @@ class SBQueue(Resource): :vartype size_in_bytes: long :ivar message_count: The number of messages in the queue. :vartype message_count: long - :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. Default is 1024. - :type max_size_in_megabytes: int - :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 status: Enumerates the possible values for the status of a messaging entity. Possible + :vartype max_delivery_count: int + :ivar status: Enumerates the possible values for the status of a messaging entity. Possible values include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", "Deleting", "Renaming", "Unknown". - :type status: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.EntityStatus - :param enable_batched_operations: Value that indicates whether server-side batched operations + :vartype status: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.EntityStatus + :ivar enable_batched_operations: Value that indicates whether server-side batched operations are enabled. - :type enable_batched_operations: bool - :param auto_delete_on_idle: ISO 8061 timeSpan idle interval after which the queue is + :vartype enable_batched_operations: bool + :ivar auto_delete_on_idle: ISO 8061 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 enable_express: A value that indicates whether Express Entities are enabled. An express + :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 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_to: Queue/Topic name to forward the messages. - :type forward_to: str - :param forward_dead_lettered_messages_to: Queue/Topic name to forward the Dead Letter message. - :type forward_dead_lettered_messages_to: str + :vartype enable_express: bool + :ivar forward_to: Queue/Topic name to forward the messages. + :vartype forward_to: str + :ivar forward_dead_lettered_messages_to: Queue/Topic name to forward the Dead Letter message. + :vartype forward_dead_lettered_messages_to: str """ _validation = { @@ -1867,6 +2180,55 @@ def __init__( forward_dead_lettered_messages_to: Optional[str] = None, **kwargs ): + """ + :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. Default is 1024. + :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 status: Enumerates the possible values for the status of a messaging entity. Possible + values include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", + "Creating", "Deleting", "Renaming", "Unknown". + :paramtype status: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.EntityStatus + :keyword enable_batched_operations: Value that indicates whether server-side batched operations + are enabled. + :paramtype enable_batched_operations: bool + :keyword auto_delete_on_idle: ISO 8061 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 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_to: Queue/Topic name to forward the messages. + :paramtype forward_to: str + :keyword forward_dead_lettered_messages_to: Queue/Topic name to forward the Dead Letter + message. + :paramtype forward_dead_lettered_messages_to: str + """ super(SBQueue, self).__init__(**kwargs) self.system_data = None self.count_details = None @@ -1895,11 +2257,11 @@ def __init__( class SBQueueListResult(msrest.serialization.Model): """The response to the List Queues operation. - :param value: Result of the List Queues operation. - :type value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBQueue] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list + :ivar value: Result of the List Queues operation. + :vartype value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBQueue] + :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of queues. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -1914,6 +2276,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of the List Queues operation. + :paramtype value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBQueue] + :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete + list of queues. + :paramtype next_link: str + """ super(SBQueueListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1924,15 +2293,15 @@ class SBSku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. Name of this SKU. Possible values include: "Basic", "Standard", + :ivar name: Required. Name of this SKU. Possible values include: "Basic", "Standard", "Premium". - :type name: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.SkuName - :param tier: The billing tier of this particular SKU. Possible values include: "Basic", + :vartype name: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.SkuName + :ivar tier: The billing tier of this particular SKU. Possible values include: "Basic", "Standard", "Premium". - :type tier: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.SkuTier - :param capacity: The specified messaging units for the tier. For Premium tier, capacity are 1,2 + :vartype tier: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.SkuTier + :ivar capacity: The specified messaging units for the tier. For Premium tier, capacity are 1,2 and 4. - :type capacity: int + :vartype capacity: int """ _validation = { @@ -1953,6 +2322,17 @@ def __init__( capacity: Optional[int] = None, **kwargs ): + """ + :keyword name: Required. Name of this SKU. Possible values include: "Basic", "Standard", + "Premium". + :paramtype name: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.SkuName + :keyword tier: The billing tier of this particular SKU. Possible values include: "Basic", + "Standard", "Premium". + :paramtype tier: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.SkuTier + :keyword capacity: The specified messaging units for the tier. For Premium tier, capacity are + 1,2 and 4. + :paramtype capacity: int + """ super(SBSku, self).__init__(**kwargs) self.name = name self.tier = tier @@ -1982,40 +2362,40 @@ class SBSubscription(Resource): :vartype updated_at: ~datetime.datetime :ivar count_details: Message count details. :vartype count_details: ~azure.mgmt.servicebus.v2021_01_01_preview.models.MessageCountDetails - :param lock_duration: ISO 8061 lock duration timespan for the subscription. The default value - is 1 minute. - :type lock_duration: ~datetime.timedelta - :param requires_session: Value indicating if a subscription supports the concept of sessions. - :type requires_session: bool - :param default_message_time_to_live: ISO 8061 Default message timespan to live value. This is + :ivar lock_duration: ISO 8061 lock duration timespan for the subscription. The default value is + 1 minute. + :vartype lock_duration: ~datetime.timedelta + :ivar requires_session: Value indicating if a subscription supports the concept of sessions. + :vartype requires_session: bool + :ivar default_message_time_to_live: ISO 8061 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_filter_evaluation_exceptions: Value that indicates whether a + :vartype default_message_time_to_live: ~datetime.timedelta + :ivar dead_lettering_on_filter_evaluation_exceptions: Value that indicates whether a subscription has dead letter support on filter evaluation exceptions. - :type dead_lettering_on_filter_evaluation_exceptions: bool - :param dead_lettering_on_message_expiration: Value that indicates whether a subscription has + :vartype dead_lettering_on_filter_evaluation_exceptions: bool + :ivar dead_lettering_on_message_expiration: Value that indicates whether a subscription 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: Number of maximum deliveries. - :type max_delivery_count: int - :param status: Enumerates the possible values for the status of a messaging entity. Possible + :vartype duplicate_detection_history_time_window: ~datetime.timedelta + :ivar max_delivery_count: Number of maximum deliveries. + :vartype max_delivery_count: int + :ivar status: Enumerates the possible values for the status of a messaging entity. Possible values include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", "Deleting", "Renaming", "Unknown". - :type status: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.EntityStatus - :param enable_batched_operations: Value that indicates whether server-side batched operations + :vartype status: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.EntityStatus + :ivar enable_batched_operations: Value that indicates whether server-side batched operations are enabled. - :type enable_batched_operations: bool - :param auto_delete_on_idle: ISO 8061 timeSpan idle interval after which the topic is + :vartype enable_batched_operations: bool + :ivar auto_delete_on_idle: ISO 8061 timeSpan idle interval after which the topic is automatically deleted. The minimum duration is 5 minutes. - :type auto_delete_on_idle: ~datetime.timedelta - :param forward_to: Queue/Topic name to forward the messages. - :type forward_to: str - :param forward_dead_lettered_messages_to: Queue/Topic name to forward the Dead Letter message. - :type forward_dead_lettered_messages_to: str + :vartype auto_delete_on_idle: ~datetime.timedelta + :ivar forward_to: Queue/Topic name to forward the messages. + :vartype forward_to: str + :ivar forward_dead_lettered_messages_to: Queue/Topic name to forward the Dead Letter message. + :vartype forward_dead_lettered_messages_to: str """ _validation = { @@ -2071,6 +2451,43 @@ def __init__( forward_dead_lettered_messages_to: Optional[str] = None, **kwargs ): + """ + :keyword lock_duration: ISO 8061 lock duration timespan for the subscription. The default value + is 1 minute. + :paramtype lock_duration: ~datetime.timedelta + :keyword requires_session: Value indicating if a subscription supports the concept of sessions. + :paramtype requires_session: bool + :keyword default_message_time_to_live: ISO 8061 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_filter_evaluation_exceptions: Value that indicates whether a + subscription has dead letter support on filter evaluation exceptions. + :paramtype dead_lettering_on_filter_evaluation_exceptions: bool + :keyword dead_lettering_on_message_expiration: Value that indicates whether a subscription 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: Number of maximum deliveries. + :paramtype max_delivery_count: int + :keyword status: Enumerates the possible values for the status of a messaging entity. Possible + values include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", + "Creating", "Deleting", "Renaming", "Unknown". + :paramtype status: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.EntityStatus + :keyword enable_batched_operations: Value that indicates whether server-side batched operations + are enabled. + :paramtype enable_batched_operations: bool + :keyword auto_delete_on_idle: ISO 8061 timeSpan idle interval after which the topic is + automatically deleted. The minimum duration is 5 minutes. + :paramtype auto_delete_on_idle: ~datetime.timedelta + :keyword forward_to: Queue/Topic name to forward the messages. + :paramtype forward_to: str + :keyword forward_dead_lettered_messages_to: Queue/Topic name to forward the Dead Letter + message. + :paramtype forward_dead_lettered_messages_to: str + """ super(SBSubscription, self).__init__(**kwargs) self.system_data = None self.message_count = None @@ -2095,11 +2512,11 @@ def __init__( class SBSubscriptionListResult(msrest.serialization.Model): """The response to the List Subscriptions operation. - :param value: Result of the List Subscriptions operation. - :type value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSubscription] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list + :ivar value: Result of the List Subscriptions operation. + :vartype value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSubscription] + :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of subscriptions. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -2114,6 +2531,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of the List Subscriptions operation. + :paramtype value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSubscription] + :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete + list of subscriptions. + :paramtype next_link: str + """ super(SBSubscriptionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -2144,37 +2568,37 @@ class SBTopic(Resource): :vartype subscription_count: int :ivar count_details: Message count details. :vartype count_details: ~azure.mgmt.servicebus.v2021_01_01_preview.models.MessageCountDetails - :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: Maximum size of the topic in megabytes, which is the size of the + :vartype default_message_time_to_live: ~datetime.timedelta + :ivar max_size_in_megabytes: Maximum size of the topic in megabytes, which is the size of the memory allocated for the topic. Default is 1024. - :type max_size_in_megabytes: int - :param requires_duplicate_detection: Value indicating if this topic requires duplicate + :vartype max_size_in_megabytes: int + :ivar requires_duplicate_detection: Value indicating if this topic requires duplicate detection. - :type requires_duplicate_detection: bool - :param duplicate_detection_history_time_window: ISO8601 timespan structure that defines the + :vartype requires_duplicate_detection: bool + :ivar duplicate_detection_history_time_window: ISO8601 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 status: Enumerates the possible values for the status of a messaging entity. Possible + :vartype enable_batched_operations: bool + :ivar status: Enumerates the possible values for the status of a messaging entity. Possible values include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", "Deleting", "Renaming", "Unknown". - :type status: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.EntityStatus - :param support_ordering: Value that indicates whether the topic supports ordering. - :type support_ordering: bool - :param auto_delete_on_idle: ISO 8601 timespan idle interval after which the topic is + :vartype status: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.EntityStatus + :ivar support_ordering: Value that indicates whether the topic supports ordering. + :vartype support_ordering: bool + :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: Value that indicates whether the topic to be partitioned across + :vartype auto_delete_on_idle: ~datetime.timedelta + :ivar enable_partitioning: Value that indicates whether the topic to be partitioned across multiple message brokers is enabled. - :type enable_partitioning: bool - :param enable_express: Value that indicates whether Express Entities are enabled. An express + :vartype enable_partitioning: bool + :ivar enable_express: 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 + :vartype enable_express: bool """ _validation = { @@ -2228,6 +2652,39 @@ def __init__( enable_express: Optional[bool] = None, **kwargs ): + """ + :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: Maximum size of the topic in megabytes, which is the size of + the memory allocated for the topic. Default is 1024. + :paramtype max_size_in_megabytes: int + :keyword requires_duplicate_detection: Value indicating if this topic requires duplicate + detection. + :paramtype requires_duplicate_detection: bool + :keyword duplicate_detection_history_time_window: ISO8601 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 status: Enumerates the possible values for the status of a messaging entity. Possible + values include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", + "Creating", "Deleting", "Renaming", "Unknown". + :paramtype status: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.EntityStatus + :keyword support_ordering: Value that indicates whether the topic supports ordering. + :paramtype support_ordering: bool + :keyword auto_delete_on_idle: ISO 8601 timespan idle interval after which the topic is + automatically deleted. The minimum duration is 5 minutes. + :paramtype auto_delete_on_idle: ~datetime.timedelta + :keyword enable_partitioning: Value that indicates whether the topic to be partitioned across + multiple message brokers is enabled. + :paramtype enable_partitioning: bool + :keyword enable_express: 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 + """ super(SBTopic, self).__init__(**kwargs) self.system_data = None self.size_in_bytes = None @@ -2251,11 +2708,11 @@ def __init__( class SBTopicListResult(msrest.serialization.Model): """The response to the List Topics operation. - :param value: Result of the List Topics operation. - :type value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBTopic] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list + :ivar value: Result of the List Topics operation. + :vartype value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBTopic] + :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of topics. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -2270,6 +2727,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of the List Topics operation. + :paramtype value: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBTopic] + :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete + list of topics. + :paramtype next_link: str + """ super(SBTopicListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -2278,14 +2742,14 @@ def __init__( class SqlFilter(msrest.serialization.Model): """Represents a filter which is a composition of an expression and an action that is executed in the pub/sub pipeline. - :param sql_expression: The SQL expression. e.g. MyProperty='ABC'. - :type sql_expression: str - :param compatibility_level: This property is reserved for future use. An integer value showing + :ivar sql_expression: The SQL expression. e.g. MyProperty='ABC'. + :vartype sql_expression: str + :ivar compatibility_level: This property is reserved for future use. An integer value showing the compatibility level, currently hard-coded to 20. - :type compatibility_level: int - :param requires_preprocessing: Value that indicates whether the rule action requires + :vartype compatibility_level: int + :ivar requires_preprocessing: Value that indicates whether the rule action requires preprocessing. - :type requires_preprocessing: bool + :vartype requires_preprocessing: bool """ _validation = { @@ -2306,6 +2770,16 @@ def __init__( requires_preprocessing: Optional[bool] = True, **kwargs ): + """ + :keyword sql_expression: The SQL expression. e.g. MyProperty='ABC'. + :paramtype sql_expression: str + :keyword compatibility_level: This property is reserved for future use. An integer value + showing the compatibility level, currently hard-coded to 20. + :paramtype compatibility_level: int + :keyword requires_preprocessing: Value that indicates whether the rule action requires + preprocessing. + :paramtype requires_preprocessing: bool + """ super(SqlFilter, self).__init__(**kwargs) self.sql_expression = sql_expression self.compatibility_level = compatibility_level @@ -2315,14 +2789,14 @@ def __init__( class SqlRuleAction(Action): """Represents set of actions written in SQL language-based syntax that is performed against a ServiceBus.Messaging.BrokeredMessage. - :param sql_expression: SQL expression. e.g. MyProperty='ABC'. - :type sql_expression: str - :param compatibility_level: This property is reserved for future use. An integer value showing + :ivar sql_expression: SQL expression. e.g. MyProperty='ABC'. + :vartype sql_expression: str + :ivar compatibility_level: This property is reserved for future use. An integer value showing the compatibility level, currently hard-coded to 20. - :type compatibility_level: int - :param requires_preprocessing: Value that indicates whether the rule action requires + :vartype compatibility_level: int + :ivar requires_preprocessing: Value that indicates whether the rule action requires preprocessing. - :type requires_preprocessing: bool + :vartype requires_preprocessing: bool """ _attribute_map = { @@ -2339,6 +2813,16 @@ def __init__( requires_preprocessing: Optional[bool] = True, **kwargs ): + """ + :keyword sql_expression: SQL expression. e.g. MyProperty='ABC'. + :paramtype sql_expression: str + :keyword compatibility_level: This property is reserved for future use. An integer value + showing the compatibility level, currently hard-coded to 20. + :paramtype compatibility_level: int + :keyword requires_preprocessing: Value that indicates whether the rule action requires + preprocessing. + :paramtype requires_preprocessing: bool + """ super(SqlRuleAction, self).__init__(sql_expression=sql_expression, compatibility_level=compatibility_level, requires_preprocessing=requires_preprocessing, **kwargs) @@ -2347,8 +2831,8 @@ class Subnet(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Required. Resource ID of Virtual Network Subnet. - :type id: str + :ivar id: Required. Resource ID of Virtual Network Subnet. + :vartype id: str """ _validation = { @@ -2365,6 +2849,10 @@ def __init__( id: str, **kwargs ): + """ + :keyword id: Required. Resource ID of Virtual Network Subnet. + :paramtype id: str + """ super(Subnet, self).__init__(**kwargs) self.id = id @@ -2372,21 +2860,22 @@ def __init__( class SystemData(msrest.serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or + ~azure.mgmt.servicebus.v2021_01_01_preview.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or + :vartype last_modified_by_type: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.CreatedByType - :param last_modified_at: The type of identity that last modified the resource. - :type last_modified_at: ~datetime.datetime + :ivar last_modified_at: The type of identity that last modified the resource. + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -2409,6 +2898,24 @@ def __init__( last_modified_at: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or + ~azure.mgmt.servicebus.v2021_01_01_preview.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or + ~azure.mgmt.servicebus.v2021_01_01_preview.models.CreatedByType + :keyword last_modified_at: The type of identity that last modified the resource. + :paramtype last_modified_at: ~datetime.datetime + """ super(SystemData, self).__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type @@ -2421,8 +2928,8 @@ def __init__( class UserAssignedIdentityProperties(msrest.serialization.Model): """UserAssignedIdentityProperties. - :param user_assigned_identity: ARM ID of user Identity selected for encryption. - :type user_assigned_identity: str + :ivar user_assigned_identity: ARM ID of user Identity selected for encryption. + :vartype user_assigned_identity: str """ _attribute_map = { @@ -2435,5 +2942,9 @@ def __init__( user_assigned_identity: Optional[str] = None, **kwargs ): + """ + :keyword user_assigned_identity: ARM ID of user Identity selected for encryption. + :paramtype user_assigned_identity: str + """ super(UserAssignedIdentityProperties, self).__init__(**kwargs) self.user_assigned_identity = user_assigned_identity diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/models/_service_bus_management_client_enums.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/models/_service_bus_management_client_enums.py index a6add4bc73f7..bb8d3c91be02 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/models/_service_bus_management_client_enums.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/models/_service_bus_management_client_enums.py @@ -6,33 +6,18 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AccessRights(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MANAGE = "Manage" SEND = "Send" LISTEN = "Listen" -class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of identity that created the resource. """ @@ -41,14 +26,14 @@ class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class DefaultAction(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DefaultAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Default Action for Network Rule Set """ ALLOW = "Allow" DENY = "Deny" -class EndPointProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class EndPointProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Provisioning state of the Private Endpoint Connection. """ @@ -59,7 +44,7 @@ class EndPointProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, En CANCELED = "Canceled" FAILED = "Failed" -class EntityStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class EntityStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Entity status. """ @@ -73,21 +58,21 @@ class EntityStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): RENAMING = "Renaming" UNKNOWN = "Unknown" -class FilterType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class FilterType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Rule filter types """ SQL_FILTER = "SqlFilter" CORRELATION_FILTER = "CorrelationFilter" -class KeyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class KeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The access key to regenerate. """ PRIMARY_KEY = "PrimaryKey" SECONDARY_KEY = "SecondaryKey" -class ManagedServiceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ManagedServiceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of managed service identity. """ @@ -96,17 +81,17 @@ class ManagedServiceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, E SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class MigrationConfigurationName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class MigrationConfigurationName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): _DEFAULT = "$default" -class NetworkRuleIPAction(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class NetworkRuleIPAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The IP Filter Action """ ALLOW = "Allow" -class PrivateLinkConnectionStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PrivateLinkConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Status of the connection. """ @@ -115,7 +100,7 @@ class PrivateLinkConnectionStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, REJECTED = "Rejected" DISCONNECTED = "Disconnected" -class ProvisioningStateDR(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningStateDR(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Provisioning state of the Alias(Disaster Recovery configuration) - possible values 'Accepted' or 'Succeeded' or 'Failed' """ @@ -124,7 +109,7 @@ class ProvisioningStateDR(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" FAILED = "Failed" -class RoleDisasterRecovery(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RoleDisasterRecovery(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """role of namespace in GEO DR - possible values 'Primary' or 'PrimaryNotReplicating' or 'Secondary' """ @@ -133,7 +118,7 @@ class RoleDisasterRecovery(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PRIMARY_NOT_REPLICATING = "PrimaryNotReplicating" SECONDARY = "Secondary" -class SkuName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Name of this SKU. """ @@ -141,7 +126,7 @@ class SkuName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): STANDARD = "Standard" PREMIUM = "Premium" -class SkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The billing tier of this particular SKU. """ @@ -149,7 +134,7 @@ class SkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): STANDARD = "Standard" PREMIUM = "Premium" -class UnavailableReason(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class UnavailableReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Specifies the reason for the unavailability of the service. """ diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_disaster_recovery_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_disaster_recovery_configs_operations.py index 1742d9b97f0f..83d09759d44e 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_disaster_recovery_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_disaster_recovery_configs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,429 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_check_name_availability_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + namespace_name: str, + alias: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + namespace_name: str, + alias: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + namespace_name: str, + alias: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_break_pairing_request( + resource_group_name: str, + namespace_name: str, + alias: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_fail_over_request( + resource_group_name: str, + namespace_name: str, + alias: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_authorization_rules_request( + resource_group_name: str, + namespace_name: str, + alias: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + alias: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_keys_request( + resource_group_name: str, + namespace_name: str, + alias: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class DisasterRecoveryConfigsOperations(object): """DisasterRecoveryConfigsOperations operations. @@ -45,14 +452,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def check_name_availability( self, - resource_group_name, # type: str - namespace_name, # type: str - parameters, # type: "_models.CheckNameAvailability" - **kwargs # type: Any - ): - # type: (...) -> "_models.CheckNameAvailabilityResult" + resource_group_name: str, + namespace_name: str, + parameters: "_models.CheckNameAvailability", + **kwargs: Any + ) -> "_models.CheckNameAvailabilityResult": """Check the give namespace name availability. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -71,38 +478,34 @@ def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CheckNameAvailability') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'CheckNameAvailability') + + request = build_check_name_availability_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) @@ -111,15 +514,17 @@ def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability"} # type: ignore + + + @distributed_trace def list( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ArmDisasterRecoveryListResult"] + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> Iterable["_models.ArmDisasterRecoveryListResult"]: """Gets all Alias(Disaster Recovery configurations). :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -127,45 +532,48 @@ def list( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ArmDisasterRecoveryListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.ArmDisasterRecoveryListResult] + :return: An iterator like instance of either ArmDisasterRecoveryListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.ArmDisasterRecoveryListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ArmDisasterRecoveryListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ArmDisasterRecoveryListResult', pipeline_response) + deserialized = self._deserialize("ArmDisasterRecoveryListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -174,30 +582,35 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs"} # type: ignore + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - namespace_name, # type: str - alias, # type: str - parameters, # type: "_models.ArmDisasterRecovery" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ArmDisasterRecovery"] + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: "_models.ArmDisasterRecovery", + **kwargs: Any + ) -> Optional["_models.ArmDisasterRecovery"]: """Creates or updates a new Alias(Disaster Recovery configuration). :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -218,39 +631,35 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ArmDisasterRecovery') - 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) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ArmDisasterRecovery') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -261,16 +670,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}'} # type: ignore - def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - alias, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + alias: str, + **kwargs: Any + ) -> None: """Deletes an Alias(Disaster Recovery configuration). :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -289,49 +700,47 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - namespace_name, # type: str - alias, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ArmDisasterRecovery" + resource_group_name: str, + namespace_name: str, + alias: str, + **kwargs: Any + ) -> "_models.ArmDisasterRecovery": """Retrieves Alias(Disaster Recovery configuration) for primary or secondary namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -350,34 +759,31 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) @@ -386,16 +792,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}'} # type: ignore - def break_pairing( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore + + + @distributed_trace + def break_pairing( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - alias, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + alias: str, + **kwargs: Any + ) -> None: """This operation disables the Disaster Recovery and stops replicating changes from primary to secondary namespaces. @@ -415,50 +823,48 @@ def break_pairing( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.break_pairing.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_break_pairing_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.break_pairing.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - break_pairing.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing'} # type: ignore + break_pairing.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing"} # type: ignore + - def fail_over( + @distributed_trace + def fail_over( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - alias, # type: str - parameters=None, # type: Optional["_models.FailoverProperties"] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional["_models.FailoverProperties"] = None, + **kwargs: Any + ) -> None: """Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -468,6 +874,7 @@ def fail_over( :param alias: The Disaster Recovery configuration name. :type alias: str :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Default value is None. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.FailoverProperties :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) @@ -479,57 +886,54 @@ def fail_over( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.fail_over.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if parameters is not None: - body_content = self._serialize.body(parameters, 'FailoverProperties') + _json = self._serialize.body(parameters, 'FailoverProperties') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + _json = None + + request = build_fail_over_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.fail_over.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - fail_over.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover'} # type: ignore + fail_over.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover"} # type: ignore + + @distributed_trace def list_authorization_rules( self, - resource_group_name, # type: str - namespace_name, # type: str - alias, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SBAuthorizationRuleListResult"] + resource_group_name: str, + namespace_name: str, + alias: str, + **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRuleListResult"]: """Gets the authorization rules for a namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -539,46 +943,50 @@ def list_authorization_rules( :param alias: The Disaster Recovery configuration name. :type alias: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRuleListResult] + :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SBAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -587,30 +995,35 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules"} # type: ignore + @distributed_trace def get_authorization_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - alias, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SBAuthorizationRule" + resource_group_name: str, + namespace_name: str, + alias: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.SBAuthorizationRule": """Gets an authorization rule for a namespace by rule name. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -631,35 +1044,32 @@ def get_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -668,17 +1078,19 @@ def get_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}'} # type: ignore + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace def list_keys( self, - resource_group_name, # type: str - namespace_name, # type: str - alias, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessKeys" + resource_group_name: str, + namespace_name: str, + alias: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.AccessKeys": """Gets the primary and secondary connection strings for the namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -699,35 +1111,32 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -736,4 +1145,6 @@ def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys'} # type: ignore + + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_migration_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_migration_configs_operations.py index 28b7801c1315..19e01dc12df2 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_migration_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_migration_configs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,25 +6,261 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_and_start_migration_request_initial( + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_complete_migration_request( + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_revert_request( + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class MigrationConfigsOperations(object): """MigrationConfigsOperations operations. @@ -47,13 +284,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MigrationConfigListResult"] + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> Iterable["_models.MigrationConfigListResult"]: """Gets all migrationConfigurations. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -61,45 +298,48 @@ def list( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MigrationConfigListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigListResult] + :return: An iterator like instance of either MigrationConfigListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.MigrationConfigListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('MigrationConfigListResult', pipeline_response) + deserialized = self._deserialize("MigrationConfigListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -108,69 +348,68 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations"} # type: ignore def _create_and_start_migration_initial( self, - resource_group_name, # type: str - namespace_name, # type: str - config_name, # type: Union[str, "_models.MigrationConfigurationName"] - parameters, # type: "_models.MigrationConfigProperties" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.MigrationConfigProperties"] + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + parameters: "_models.MigrationConfigProperties", + **kwargs: Any + ) -> Optional["_models.MigrationConfigProperties"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.MigrationConfigProperties"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_and_start_migration_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'MigrationConfigProperties') - 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) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'MigrationConfigProperties') + + request = build_create_and_start_migration_request_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_and_start_migration_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -180,17 +419,19 @@ def _create_and_start_migration_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_and_start_migration_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}'} # type: ignore + _create_and_start_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + + + @distributed_trace def begin_create_and_start_migration( self, - resource_group_name, # type: str - namespace_name, # type: str - config_name, # type: Union[str, "_models.MigrationConfigurationName"] - parameters, # type: "_models.MigrationConfigProperties" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.MigrationConfigProperties"] + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + parameters: "_models.MigrationConfigProperties", + **kwargs: Any + ) -> LROPoller["_models.MigrationConfigProperties"]: """Creates Migration configuration and starts migration of entities from Standard to Premium namespace. @@ -199,19 +440,26 @@ def begin_create_and_start_migration( :param namespace_name: The namespace name. :type namespace_name: str :param config_name: The configuration name. Should always be "$default". - :type config_name: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigurationName + :type config_name: str or + ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigurationName :param parameters: Parameters required to create Migration Configuration. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigProperties :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either MigrationConfigProperties or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigProperties] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MigrationConfigProperties or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigProperties] + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.MigrationConfigProperties"] lro_delay = kwargs.pop( @@ -225,28 +473,22 @@ def begin_create_and_start_migration( namespace_name=namespace_name, config_name=config_name, parameters=parameters, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -256,18 +498,18 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_and_start_migration.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def delete( + begin_create_and_start_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - config_name, # type: Union[str, "_models.MigrationConfigurationName"] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + **kwargs: Any + ) -> None: """Deletes a MigrationConfiguration. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -275,7 +517,8 @@ def delete( :param namespace_name: The namespace name. :type namespace_name: str :param config_name: The configuration name. Should always be "$default". - :type config_name: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigurationName + :type config_name: str or + ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigurationName :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -286,49 +529,47 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - namespace_name, # type: str - config_name, # type: Union[str, "_models.MigrationConfigurationName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.MigrationConfigProperties" + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + **kwargs: Any + ) -> "_models.MigrationConfigProperties": """Retrieves Migration Config. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -336,7 +577,8 @@ def get( :param namespace_name: The namespace name. :type namespace_name: str :param config_name: The configuration name. Should always be "$default". - :type config_name: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigurationName + :type config_name: str or + ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigurationName :keyword callable cls: A custom type or function that will be passed the direct response :return: MigrationConfigProperties, or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigProperties @@ -347,34 +589,31 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) @@ -383,16 +622,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}'} # type: ignore - def complete_migration( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + + + @distributed_trace + def complete_migration( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - config_name, # type: Union[str, "_models.MigrationConfigurationName"] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + **kwargs: Any + ) -> None: """This operation Completes Migration of entities by pointing the connection strings to Premium namespace and any entities created after the operation will be under Premium Namespace. CompleteMigration operation will fail when entity migration is in-progress. @@ -402,7 +643,8 @@ def complete_migration( :param namespace_name: The namespace name. :type namespace_name: str :param config_name: The configuration name. Should always be "$default". - :type config_name: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigurationName + :type config_name: str or + ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigurationName :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -413,49 +655,47 @@ def complete_migration( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.complete_migration.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_complete_migration_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.complete_migration.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - complete_migration.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade'} # type: ignore + complete_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade"} # type: ignore - def revert( + + @distributed_trace + def revert( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - config_name, # type: Union[str, "_models.MigrationConfigurationName"] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + **kwargs: Any + ) -> None: """This operation reverts Migration. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -463,7 +703,8 @@ def revert( :param namespace_name: The namespace name. :type namespace_name: str :param config_name: The configuration name. Should always be "$default". - :type config_name: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigurationName + :type config_name: str or + ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigurationName :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -474,37 +715,35 @@ def revert( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.revert.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_revert_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.revert.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - revert.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert'} # type: ignore + revert.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_namespaces_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_namespaces_operations.py index f2a96e6c5ffd..3757ad3794dc 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_namespaces_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_namespaces_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,25 +6,651 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_create_or_update_network_rule_set_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_network_rule_set_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_network_rule_sets_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_authorization_rules_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_keys_request( + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_regenerate_keys_request( + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_check_name_availability_request( + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) class NamespacesOperations(object): """NamespacesOperations operations. @@ -47,51 +674,52 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SBNamespaceListResult"] + **kwargs: Any + ) -> Iterable["_models.SBNamespaceListResult"]: """Gets all the available namespaces within the subscription, irrespective of the resource groups. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBNamespaceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespaceListResult] + :return: An iterator like instance of either SBNamespaceListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespaceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBNamespaceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SBNamespaceListResult', pipeline_response) + deserialized = self._deserialize("SBNamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -100,70 +728,77 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces"} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SBNamespaceListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.SBNamespaceListResult"]: """Gets the available namespaces within a resource group. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBNamespaceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespaceListResult] + :return: An iterator like instance of either SBNamespaceListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespaceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBNamespaceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SBNamespaceListResult', pipeline_response) + deserialized = self._deserialize("SBNamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -172,67 +807,66 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces"} # type: ignore def _create_or_update_initial( self, - resource_group_name, # type: str - namespace_name, # type: str - parameters, # type: "_models.SBNamespace" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.SBNamespace"] + resource_group_name: str, + namespace_name: str, + parameters: "_models.SBNamespace", + **kwargs: Any + ) -> Optional["_models.SBNamespace"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.SBNamespace"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBNamespace') - 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) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBNamespace') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -245,16 +879,18 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - namespace_name, # type: str - parameters, # type: "_models.SBNamespace" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.SBNamespace"] + resource_group_name: str, + namespace_name: str, + parameters: "_models.SBNamespace", + **kwargs: Any + ) -> LROPoller["_models.SBNamespace"]: """Creates or updates a service namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. @@ -266,14 +902,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either SBNamespace or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either SBNamespace or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace] + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.SBNamespace"] lro_delay = kwargs.pop( @@ -286,27 +928,22 @@ def begin_create_or_update( resource_group_name=resource_group_name, namespace_name=namespace_name, parameters=parameters, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('SBNamespace', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -316,63 +953,59 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def _delete_initial( + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + - def begin_delete( + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes an existing namespace. This operation also removes all associated resources under the namespace. @@ -382,14 +1015,17 @@ def begin_delete( :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( @@ -401,24 +1037,18 @@ def begin_delete( raw_result = self._delete_initial( resource_group_name=resource_group_name, namespace_name=namespace_name, + api_version=api_version, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -428,17 +1058,17 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SBNamespace" + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> "_models.SBNamespace": """Gets a description for the specified namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -455,33 +1085,30 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBNamespace', pipeline_response) @@ -490,16 +1117,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + + @distributed_trace def update( self, - resource_group_name, # type: str - namespace_name, # type: str - parameters, # type: "_models.SBNamespaceUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.SBNamespace"] + resource_group_name: str, + namespace_name: str, + parameters: "_models.SBNamespaceUpdateParameters", + **kwargs: Any + ) -> Optional["_models.SBNamespace"]: """Updates a service namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. @@ -519,38 +1148,34 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -564,16 +1189,18 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + + @distributed_trace def create_or_update_network_rule_set( self, - resource_group_name, # type: str - namespace_name, # type: str - parameters, # type: "_models.NetworkRuleSet" - **kwargs # type: Any - ): - # type: (...) -> "_models.NetworkRuleSet" + resource_group_name: str, + namespace_name: str, + parameters: "_models.NetworkRuleSet", + **kwargs: Any + ) -> "_models.NetworkRuleSet": """Create or update NetworkRuleSet for a Namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -592,38 +1219,34 @@ def create_or_update_network_rule_set( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_network_rule_set.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'NetworkRuleSet') - 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) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'NetworkRuleSet') + + request = build_create_or_update_network_rule_set_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_network_rule_set.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('NetworkRuleSet', pipeline_response) @@ -632,15 +1255,17 @@ def create_or_update_network_rule_set( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_network_rule_set.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default'} # type: ignore + create_or_update_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore + + + @distributed_trace def get_network_rule_set( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.NetworkRuleSet" + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> "_models.NetworkRuleSet": """Gets NetworkRuleSet for a Namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -657,33 +1282,30 @@ def get_network_rule_set( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_network_rule_set.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_network_rule_set_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_network_rule_set.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('NetworkRuleSet', pipeline_response) @@ -692,15 +1314,17 @@ def get_network_rule_set( return cls(pipeline_response, deserialized, {}) return deserialized - get_network_rule_set.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default'} # type: ignore + get_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore + + + @distributed_trace def list_network_rule_sets( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.NetworkRuleSetListResult"] + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> Iterable["_models.NetworkRuleSetListResult"]: """Gets list of NetworkRuleSet for a Namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -708,45 +1332,48 @@ def list_network_rule_sets( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NetworkRuleSetListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleSetListResult] + :return: An iterator like instance of either NetworkRuleSetListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkRuleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_network_rule_sets.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_network_rule_sets_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_network_rule_sets.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_network_rule_sets_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('NetworkRuleSetListResult', pipeline_response) + deserialized = self._deserialize("NetworkRuleSetListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -755,28 +1382,33 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_network_rule_sets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets'} # type: ignore + list_network_rule_sets.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets"} # type: ignore + @distributed_trace def list_authorization_rules( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SBAuthorizationRuleListResult"] + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRuleListResult"]: """Gets the authorization rules for a namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -784,45 +1416,48 @@ def list_authorization_rules( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRuleListResult] + :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SBAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -831,30 +1466,35 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules"} # type: ignore + @distributed_trace def create_or_update_authorization_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - authorization_rule_name, # type: str - parameters, # type: "_models.SBAuthorizationRule" - **kwargs # type: Any - ): - # type: (...) -> "_models.SBAuthorizationRule" + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: "_models.SBAuthorizationRule", + **kwargs: Any + ) -> "_models.SBAuthorizationRule": """Creates or updates an authorization rule for a namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -875,39 +1515,35 @@ def create_or_update_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBAuthorizationRule') - 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) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBAuthorizationRule') + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -916,16 +1552,18 @@ def create_or_update_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}'} # type: ignore - def delete_authorization_rule( + create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace + def delete_authorization_rule( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> None: """Deletes a namespace authorization rule. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -944,49 +1582,47 @@ def delete_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}'} # type: ignore + delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore + + @distributed_trace def get_authorization_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SBAuthorizationRule" + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.SBAuthorizationRule": """Gets an authorization rule for a namespace by rule name. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -1005,34 +1641,31 @@ def get_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -1041,16 +1674,18 @@ def get_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}'} # type: ignore + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace def list_keys( self, - resource_group_name, # type: str - namespace_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessKeys" + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.AccessKeys": """Gets the primary and secondary connection strings for the namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -1069,34 +1704,31 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -1105,17 +1737,19 @@ def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore + + + @distributed_trace def regenerate_keys( self, - resource_group_name, # type: str - namespace_name, # type: str - authorization_rule_name, # type: str - parameters, # type: "_models.RegenerateAccessKeyParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessKeys" + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: "_models.RegenerateAccessKeyParameters", + **kwargs: Any + ) -> "_models.AccessKeys": """Regenerates the primary or secondary connection strings for the namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -1125,7 +1759,8 @@ def regenerate_keys( :param authorization_rule_name: The authorization rule name. :type authorization_rule_name: str :param parameters: Parameters supplied to regenerate the authorization rule. - :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.RegenerateAccessKeyParameters + :type parameters: + ~azure.mgmt.servicebus.v2021_01_01_preview.models.RegenerateAccessKeyParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessKeys, or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys @@ -1136,39 +1771,35 @@ def regenerate_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -1177,14 +1808,16 @@ def regenerate_keys( return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys'} # type: ignore + regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + + + @distributed_trace def check_name_availability( self, - parameters, # type: "_models.CheckNameAvailability" - **kwargs # type: Any - ): - # type: (...) -> "_models.CheckNameAvailabilityResult" + parameters: "_models.CheckNameAvailability", + **kwargs: Any + ) -> "_models.CheckNameAvailabilityResult": """Check the give namespace name availability. :param parameters: Parameters to check availability of the given namespace name. @@ -1199,36 +1832,32 @@ def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CheckNameAvailability') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'CheckNameAvailability') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) @@ -1237,4 +1866,6 @@ def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability'} # type: ignore + + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_operations.py index 94f904c4fa17..ee4a7d48c08f 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,50 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.ServiceBus/operations") + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,47 +73,49 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationListResult"] + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: """Lists all of the available ServiceBus REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.OperationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -94,17 +124,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.ServiceBus/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.ServiceBus/operations"} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_private_endpoint_connections_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_private_endpoint_connections_operations.py index 2e35b3bb49f7..46f94228ea88 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_private_endpoint_connections_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_private_endpoint_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,25 +6,185 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + private_endpoint_connection_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class PrivateEndpointConnectionsOperations(object): """PrivateEndpointConnectionsOperations operations. @@ -47,13 +208,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PrivateEndpointConnectionListResult"] + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnectionListResult"]: """Gets the available PrivateEndpointConnections within a namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -61,45 +222,48 @@ def list( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateEndpointConnectionListResult] + :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PrivateEndpointConnectionListResult', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -108,30 +272,35 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections"} # type: ignore + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - namespace_name, # type: str - private_endpoint_connection_name, # type: str - parameters, # type: "_models.PrivateEndpointConnection" - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateEndpointConnection" + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: "_models.PrivateEndpointConnection", + **kwargs: Any + ) -> "_models.PrivateEndpointConnection": """Creates or updates PrivateEndpointConnections of service namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -153,39 +322,35 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PrivateEndpointConnection') - 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) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + namespace_name=namespace_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -198,64 +363,62 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - def _delete_initial( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + + def _delete_initial( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - def begin_delete( + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes an existing Private Endpoint Connection. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -266,14 +429,17 @@ def begin_delete( :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( @@ -286,25 +452,18 @@ def begin_delete( resource_group_name=resource_group_name, namespace_name=namespace_name, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -314,18 +473,18 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - namespace_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateEndpointConnection" + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> "_models.PrivateEndpointConnection": """Gets a description for the specified Private Endpoint Connection. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -344,34 +503,31 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) @@ -380,4 +536,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_private_link_resources_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_private_link_resources_operations.py index da52a0b09b34..ca91aec70390 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_private_link_resources_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_private_link_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,59 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class PrivateLinkResourcesOperations(object): """PrivateLinkResourcesOperations operations. @@ -44,13 +82,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateLinkResourcesListResult" + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> "_models.PrivateLinkResourcesListResult": """Gets lists of resources that supports Privatelinks. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -67,33 +105,30 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PrivateLinkResourcesListResult', pipeline_response) @@ -102,4 +137,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_queues_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_queues_operations.py index c1af17fdfa9b..f40b8e1ecbd9 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_queues_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_queues_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,444 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_authorization_rules_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_keys_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_regenerate_keys_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_namespace_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + *, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if skip is not None: + _query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + if top is not None: + _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class QueuesOperations(object): """QueuesOperations operations. @@ -45,14 +467,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_authorization_rules( self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SBAuthorizationRuleListResult"] + resource_group_name: str, + namespace_name: str, + queue_name: str, + **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRuleListResult"]: """Gets all authorization rules for a queue. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -62,46 +484,50 @@ def list_authorization_rules( :param queue_name: The queue name. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRuleListResult] + :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SBAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,31 +536,36 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules"} # type: ignore + @distributed_trace def create_or_update_authorization_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - authorization_rule_name, # type: str - parameters, # type: "_models.SBAuthorizationRule" - **kwargs # type: Any - ): - # type: (...) -> "_models.SBAuthorizationRule" + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: "_models.SBAuthorizationRule", + **kwargs: Any + ) -> "_models.SBAuthorizationRule": """Creates an authorization rule for a queue. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -157,40 +588,36 @@ def create_or_update_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBAuthorizationRule') - 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) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBAuthorizationRule') + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -199,17 +626,19 @@ def create_or_update_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}'} # type: ignore - def delete_authorization_rule( + create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace + def delete_authorization_rule( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> None: """Deletes a queue authorization rule. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -230,51 +659,49 @@ def delete_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}'} # type: ignore + delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + @distributed_trace def get_authorization_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SBAuthorizationRule" + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.SBAuthorizationRule": """Gets an authorization rule for a queue by rule name. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -295,35 +722,32 @@ def get_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -332,17 +756,19 @@ def get_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}'} # type: ignore + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace def list_keys( self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessKeys" + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.AccessKeys": """Primary and secondary connection strings to the queue. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -363,35 +789,32 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -400,18 +823,20 @@ def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore + + + @distributed_trace def regenerate_keys( self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - authorization_rule_name, # type: str - parameters, # type: "_models.RegenerateAccessKeyParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessKeys" + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: "_models.RegenerateAccessKeyParameters", + **kwargs: Any + ) -> "_models.AccessKeys": """Regenerates the primary or secondary connection strings to the queue. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -423,7 +848,8 @@ def regenerate_keys( :param authorization_rule_name: The authorization rule name. :type authorization_rule_name: str :param parameters: Parameters supplied to regenerate the authorization rule. - :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.RegenerateAccessKeyParameters + :type parameters: + ~azure.mgmt.servicebus.v2021_01_01_preview.models.RegenerateAccessKeyParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessKeys, or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys @@ -434,40 +860,36 @@ def regenerate_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -476,17 +898,19 @@ def regenerate_keys( return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys'} # type: ignore + regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + + + @distributed_trace def list_by_namespace( self, - resource_group_name, # type: str - namespace_name, # type: str - skip=None, # type: Optional[int] - top=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SBQueueListResult"] + resource_group_name: str, + namespace_name: str, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.SBQueueListResult"]: """Gets the queues within a namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -495,54 +919,57 @@ def list_by_namespace( :type namespace_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. + parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip: int :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SBQueueListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBQueueListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBQueueListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBQueueListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_namespace.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', maximum=1000, minimum=0) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=self.list_by_namespace.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SBQueueListResult', pipeline_response) + deserialized = self._deserialize("SBQueueListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -551,30 +978,35 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_namespace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues'} # type: ignore + list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues"} # type: ignore + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - parameters, # type: "_models.SBQueue" - **kwargs # type: Any - ): - # type: (...) -> "_models.SBQueue" + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: "_models.SBQueue", + **kwargs: Any + ) -> "_models.SBQueue": """Creates or updates a Service Bus queue. This operation is idempotent. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -595,39 +1027,35 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBQueue') - 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) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBQueue') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBQueue', pipeline_response) @@ -636,16 +1064,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}'} # type: ignore - def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + queue_name: str, + **kwargs: Any + ) -> None: """Deletes a queue from the specified namespace in a resource group. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -664,49 +1094,47 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SBQueue" + resource_group_name: str, + namespace_name: str, + queue_name: str, + **kwargs: Any + ) -> "_models.SBQueue": """Returns a description for the specified queue. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -725,34 +1153,31 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBQueue', pipeline_response) @@ -761,4 +1186,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_rules_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_rules_operations.py index 24184888dfe3..8247d2b1f205 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_rules_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_rules_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,206 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_subscriptions_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + subscription_id: str, + *, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if skip is not None: + _query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + if top is not None: + _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class RulesOperations(object): """RulesOperations operations. @@ -45,17 +229,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_subscriptions( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - subscription_name, # type: str - skip=None, # type: Optional[int] - top=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RuleListResult"] + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.RuleListResult"]: """List all the rules within given topic-subscription. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -68,56 +252,61 @@ def list_by_subscriptions( :type subscription_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. + parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip: int :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.RuleListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.RuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscriptions.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', maximum=1000, minimum=0) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscriptions_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=self.list_by_subscriptions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscriptions_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RuleListResult', pipeline_response) + deserialized = self._deserialize("RuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -126,32 +315,37 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_subscriptions.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules'} # type: ignore + list_by_subscriptions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules"} # type: ignore + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - subscription_name, # type: str - rule_name, # type: str - parameters, # type: "_models.Rule" - **kwargs # type: Any - ): - # type: (...) -> "_models.Rule" + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: "_models.Rule", + **kwargs: Any + ) -> "_models.Rule": """Creates a new rule and updates an existing rule. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -176,41 +370,37 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Rule') - 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) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Rule') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Rule', pipeline_response) @@ -219,18 +409,20 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}'} # type: ignore - def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - subscription_name, # type: str - rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + **kwargs: Any + ) -> None: """Deletes an existing rule. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -253,53 +445,51 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - subscription_name, # type: str - rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Rule" + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + **kwargs: Any + ) -> "_models.Rule": """Retrieves the description for the specified rule. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -322,36 +512,33 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Rule', pipeline_response) @@ -360,4 +547,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_subscriptions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_subscriptions_operations.py index 3fe7d2ae0b5b..d030481fa5c6 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_subscriptions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_subscriptions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,198 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_topic_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_id: str, + *, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if skip is not None: + _query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + if top is not None: + _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class SubscriptionsOperations(object): """SubscriptionsOperations operations. @@ -45,16 +221,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_topic( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - skip=None, # type: Optional[int] - top=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SBSubscriptionListResult"] + resource_group_name: str, + namespace_name: str, + topic_name: str, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.SBSubscriptionListResult"]: """List all the subscriptions under a specified topic. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -65,55 +241,60 @@ def list_by_topic( :type topic_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. + parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip: int :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBSubscriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSubscriptionListResult] + :return: An iterator like instance of either SBSubscriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSubscriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBSubscriptionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_topic.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', maximum=1000, minimum=0) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_topic_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=self.list_by_topic.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_topic_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SBSubscriptionListResult', pipeline_response) + deserialized = self._deserialize("SBSubscriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -122,31 +303,36 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_topic.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions'} # type: ignore + list_by_topic.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions"} # type: ignore + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - subscription_name, # type: str - parameters, # type: "_models.SBSubscription" - **kwargs # type: Any - ): - # type: (...) -> "_models.SBSubscription" + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: "_models.SBSubscription", + **kwargs: Any + ) -> "_models.SBSubscription": """Creates a topic subscription. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -169,40 +355,36 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBSubscription') - 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) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBSubscription') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBSubscription', pipeline_response) @@ -211,17 +393,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}'} # type: ignore - def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - subscription_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + **kwargs: Any + ) -> None: """Deletes a subscription from the specified topic. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -242,51 +426,49 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - subscription_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SBSubscription" + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + **kwargs: Any + ) -> "_models.SBSubscription": """Returns a subscription description for the specified topic. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -307,35 +489,32 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBSubscription', pipeline_response) @@ -344,4 +523,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_topics_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_topics_operations.py index 8976202c588a..1f7348b79cb4 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_topics_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_topics_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,444 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_authorization_rules_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_delete_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_keys_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_regenerate_keys_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_namespace_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + *, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if skip is not None: + _query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + if top is not None: + _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class TopicsOperations(object): """TopicsOperations operations. @@ -45,14 +467,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_authorization_rules( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SBAuthorizationRuleListResult"] + resource_group_name: str, + namespace_name: str, + topic_name: str, + **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRuleListResult"]: """Gets authorization rules for a topic. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -62,46 +484,50 @@ def list_authorization_rules( :param topic_name: The topic name. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRuleListResult] + :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SBAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,31 +536,36 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules"} # type: ignore + @distributed_trace def create_or_update_authorization_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - authorization_rule_name, # type: str - parameters, # type: "_models.SBAuthorizationRule" - **kwargs # type: Any - ): - # type: (...) -> "_models.SBAuthorizationRule" + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: "_models.SBAuthorizationRule", + **kwargs: Any + ) -> "_models.SBAuthorizationRule": """Creates an authorization rule for the specified topic. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -157,40 +588,36 @@ def create_or_update_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBAuthorizationRule') - 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) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBAuthorizationRule') + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -199,17 +626,19 @@ def create_or_update_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}'} # type: ignore + create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace def get_authorization_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SBAuthorizationRule" + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.SBAuthorizationRule": """Returns the specified authorization rule. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -230,35 +659,32 @@ def get_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -267,17 +693,19 @@ def get_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}'} # type: ignore - def delete_authorization_rule( + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace + def delete_authorization_rule( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> None: """Deletes a topic authorization rule. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -298,51 +726,49 @@ def delete_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}'} # type: ignore + delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + @distributed_trace def list_keys( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessKeys" + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.AccessKeys": """Gets the primary and secondary connection strings for the topic. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -363,35 +789,32 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -400,18 +823,20 @@ def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore + + + @distributed_trace def regenerate_keys( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - authorization_rule_name, # type: str - parameters, # type: "_models.RegenerateAccessKeyParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessKeys" + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: "_models.RegenerateAccessKeyParameters", + **kwargs: Any + ) -> "_models.AccessKeys": """Regenerates primary or secondary connection strings for the topic. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -423,7 +848,8 @@ def regenerate_keys( :param authorization_rule_name: The authorization rule name. :type authorization_rule_name: str :param parameters: Parameters supplied to regenerate the authorization rule. - :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.RegenerateAccessKeyParameters + :type parameters: + ~azure.mgmt.servicebus.v2021_01_01_preview.models.RegenerateAccessKeyParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessKeys, or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys @@ -434,40 +860,36 @@ def regenerate_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -476,17 +898,19 @@ def regenerate_keys( return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys'} # type: ignore + regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + + + @distributed_trace def list_by_namespace( self, - resource_group_name, # type: str - namespace_name, # type: str - skip=None, # type: Optional[int] - top=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SBTopicListResult"] + resource_group_name: str, + namespace_name: str, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.SBTopicListResult"]: """Gets all the topics in a namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -495,54 +919,57 @@ def list_by_namespace( :type namespace_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. + parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip: int :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SBTopicListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBTopicListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBTopicListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBTopicListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_namespace.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', maximum=1000, minimum=0) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=self.list_by_namespace.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SBTopicListResult', pipeline_response) + deserialized = self._deserialize("SBTopicListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -551,30 +978,35 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_namespace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics'} # type: ignore + list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics"} # type: ignore + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - parameters, # type: "_models.SBTopic" - **kwargs # type: Any - ): - # type: (...) -> "_models.SBTopic" + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: "_models.SBTopic", + **kwargs: Any + ) -> "_models.SBTopic": """Creates a topic in the specified namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -595,39 +1027,35 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBTopic') - 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) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBTopic') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBTopic', pipeline_response) @@ -636,16 +1064,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}'} # type: ignore - def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + topic_name: str, + **kwargs: Any + ) -> None: """Deletes a topic from the specified namespace and resource group. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -664,49 +1094,47 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SBTopic" + resource_group_name: str, + namespace_name: str, + topic_name: str, + **kwargs: Any + ) -> "_models.SBTopic": """Returns a description for the specified topic. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -725,34 +1153,31 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBTopic', pipeline_response) @@ -761,4 +1186,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/__init__.py index e6ef471ff03a..aa0384448e69 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ServiceBusManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_configuration.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_configuration.py index fadc06e080d8..91585e68502c 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_configuration.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_configuration.py @@ -6,22 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -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 @@ -29,26 +27,31 @@ class ServiceBusManagementClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-06-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-servicebus/{}'.format(VERSION)) self._configure(**kwargs) @@ -68,4 +71,4 @@ def _configure( 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) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_metadata.json b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_metadata.json index c6bd6f302caf..d5209a713f9d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_metadata.json +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_metadata.json @@ -5,13 +5,13 @@ "name": "ServiceBusManagementClient", "filename": "_service_bus_management_client", "description": "Azure Service Bus client for managing Namespace.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "namespaces": "NamespacesOperations", diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_service_bus_management_client.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_service_bus_management_client.py index d929c4a3fa7c..93f2bf10c05e 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_service_bus_management_client.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_service_bus_management_client.py @@ -6,47 +6,41 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient -from ._configuration import ServiceBusManagementClientConfiguration -from .operations import NamespacesOperations -from .operations import PrivateEndpointConnectionsOperations -from .operations import PrivateLinkResourcesOperations -from .operations import Operations -from .operations import DisasterRecoveryConfigsOperations -from .operations import MigrationConfigsOperations -from .operations import QueuesOperations -from .operations import TopicsOperations -from .operations import RulesOperations -from .operations import SubscriptionsOperations from . import models +from ._configuration import ServiceBusManagementClientConfiguration +from .operations import DisasterRecoveryConfigsOperations, MigrationConfigsOperations, NamespacesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueuesOperations, RulesOperations, SubscriptionsOperations, TopicsOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class ServiceBusManagementClient(object): +class ServiceBusManagementClient: # pylint: disable=too-many-instance-attributes """Azure Service Bus client for managing Namespace. :ivar namespaces: NamespacesOperations operations :vartype namespaces: azure.mgmt.servicebus.v2021_06_01_preview.operations.NamespacesOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: azure.mgmt.servicebus.v2021_06_01_preview.operations.PrivateEndpointConnectionsOperations + :vartype private_endpoint_connections: + azure.mgmt.servicebus.v2021_06_01_preview.operations.PrivateEndpointConnectionsOperations :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: azure.mgmt.servicebus.v2021_06_01_preview.operations.PrivateLinkResourcesOperations + :vartype private_link_resources: + azure.mgmt.servicebus.v2021_06_01_preview.operations.PrivateLinkResourcesOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.servicebus.v2021_06_01_preview.operations.Operations :ivar disaster_recovery_configs: DisasterRecoveryConfigsOperations operations - :vartype disaster_recovery_configs: azure.mgmt.servicebus.v2021_06_01_preview.operations.DisasterRecoveryConfigsOperations + :vartype disaster_recovery_configs: + azure.mgmt.servicebus.v2021_06_01_preview.operations.DisasterRecoveryConfigsOperations :ivar migration_configs: MigrationConfigsOperations operations - :vartype migration_configs: azure.mgmt.servicebus.v2021_06_01_preview.operations.MigrationConfigsOperations + :vartype migration_configs: + azure.mgmt.servicebus.v2021_06_01_preview.operations.MigrationConfigsOperations :ivar queues: QueuesOperations operations :vartype queues: azure.mgmt.servicebus.v2021_06_01_preview.operations.QueuesOperations :ivar topics: TopicsOperations operations @@ -54,71 +48,73 @@ class ServiceBusManagementClient(object): :ivar rules: RulesOperations operations :vartype rules: azure.mgmt.servicebus.v2021_06_01_preview.operations.RulesOperations :ivar subscriptions: SubscriptionsOperations operations - :vartype subscriptions: azure.mgmt.servicebus.v2021_06_01_preview.operations.SubscriptionsOperations + :vartype subscriptions: + azure.mgmt.servicebus.v2021_06_01_preview.operations.SubscriptionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ServiceBusManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ServiceBusManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - - self.namespaces = NamespacesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.disaster_recovery_configs = DisasterRecoveryConfigsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.migration_configs = MigrationConfigsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.queues = QueuesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.topics = TopicsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.rules = RulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + self._serialize.client_side_validation = False + self.namespaces = NamespacesOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.disaster_recovery_configs = DisasterRecoveryConfigsOperations(self._client, self._config, self._serialize, self._deserialize) + self.migration_configs = MigrationConfigsOperations(self._client, self._config, self._serialize, self._deserialize) + self.queues = QueuesOperations(self._client, self._config, self._serialize, self._deserialize) + self.topics = TopicsOperations(self._client, self._config, self._serialize, self._deserialize) + self.rules = RulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations(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. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_vendor.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# 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 azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_version.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_version.py index e7ffc58c0429..e5754a47ce68 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_version.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "7.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/__init__.py index 9016cbc21795..1b5398b4946f 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/__init__.py @@ -8,3 +8,8 @@ from ._service_bus_management_client import ServiceBusManagementClient __all__ = ['ServiceBusManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/_configuration.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/_configuration.py index a5dc95262617..6b3e32290dc5 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/_configuration.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -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 @@ -27,8 +27,12 @@ class ServiceBusManagementClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -37,15 +41,17 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-06-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-servicebus/{}'.format(VERSION)) self._configure(**kwargs) @@ -64,4 +70,4 @@ def _configure( 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) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/_service_bus_management_client.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/_service_bus_management_client.py index 43952da13e37..857e97c25d21 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/_service_bus_management_client.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/_service_bus_management_client.py @@ -6,45 +6,42 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient -from ._configuration import ServiceBusManagementClientConfiguration -from .operations import NamespacesOperations -from .operations import PrivateEndpointConnectionsOperations -from .operations import PrivateLinkResourcesOperations -from .operations import Operations -from .operations import DisasterRecoveryConfigsOperations -from .operations import MigrationConfigsOperations -from .operations import QueuesOperations -from .operations import TopicsOperations -from .operations import RulesOperations -from .operations import SubscriptionsOperations from .. import models +from ._configuration import ServiceBusManagementClientConfiguration +from .operations import DisasterRecoveryConfigsOperations, MigrationConfigsOperations, NamespacesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueuesOperations, RulesOperations, SubscriptionsOperations, TopicsOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class ServiceBusManagementClient(object): +class ServiceBusManagementClient: # pylint: disable=too-many-instance-attributes """Azure Service Bus client for managing Namespace. :ivar namespaces: NamespacesOperations operations - :vartype namespaces: azure.mgmt.servicebus.v2021_06_01_preview.aio.operations.NamespacesOperations + :vartype namespaces: + azure.mgmt.servicebus.v2021_06_01_preview.aio.operations.NamespacesOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: azure.mgmt.servicebus.v2021_06_01_preview.aio.operations.PrivateEndpointConnectionsOperations + :vartype private_endpoint_connections: + azure.mgmt.servicebus.v2021_06_01_preview.aio.operations.PrivateEndpointConnectionsOperations :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: azure.mgmt.servicebus.v2021_06_01_preview.aio.operations.PrivateLinkResourcesOperations + :vartype private_link_resources: + azure.mgmt.servicebus.v2021_06_01_preview.aio.operations.PrivateLinkResourcesOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.servicebus.v2021_06_01_preview.aio.operations.Operations :ivar disaster_recovery_configs: DisasterRecoveryConfigsOperations operations - :vartype disaster_recovery_configs: azure.mgmt.servicebus.v2021_06_01_preview.aio.operations.DisasterRecoveryConfigsOperations + :vartype disaster_recovery_configs: + azure.mgmt.servicebus.v2021_06_01_preview.aio.operations.DisasterRecoveryConfigsOperations :ivar migration_configs: MigrationConfigsOperations operations - :vartype migration_configs: azure.mgmt.servicebus.v2021_06_01_preview.aio.operations.MigrationConfigsOperations + :vartype migration_configs: + azure.mgmt.servicebus.v2021_06_01_preview.aio.operations.MigrationConfigsOperations :ivar queues: QueuesOperations operations :vartype queues: azure.mgmt.servicebus.v2021_06_01_preview.aio.operations.QueuesOperations :ivar topics: TopicsOperations operations @@ -52,69 +49,73 @@ class ServiceBusManagementClient(object): :ivar rules: RulesOperations operations :vartype rules: azure.mgmt.servicebus.v2021_06_01_preview.aio.operations.RulesOperations :ivar subscriptions: SubscriptionsOperations operations - :vartype subscriptions: azure.mgmt.servicebus.v2021_06_01_preview.aio.operations.SubscriptionsOperations + :vartype subscriptions: + azure.mgmt.servicebus.v2021_06_01_preview.aio.operations.SubscriptionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = ServiceBusManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ServiceBusManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.namespaces = NamespacesOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.disaster_recovery_configs = DisasterRecoveryConfigsOperations(self._client, self._config, self._serialize, self._deserialize) + self.migration_configs = MigrationConfigsOperations(self._client, self._config, self._serialize, self._deserialize) + self.queues = QueuesOperations(self._client, self._config, self._serialize, self._deserialize) + self.topics = TopicsOperations(self._client, self._config, self._serialize, self._deserialize) + self.rules = RulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscriptions = SubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.namespaces = NamespacesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.disaster_recovery_configs = DisasterRecoveryConfigsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.migration_configs = MigrationConfigsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.queues = QueuesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.topics = TopicsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.rules = RulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.subscriptions = SubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_disaster_recovery_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_disaster_recovery_configs_operations.py index 957e6aefc65a..42e874071e81 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_disaster_recovery_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_disaster_recovery_configs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._disaster_recovery_configs_operations import build_break_pairing_request, build_check_name_availability_request, build_create_or_update_request, build_delete_request, build_fail_over_request, build_get_authorization_rule_request, build_get_request, build_list_authorization_rules_request, build_list_keys_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def check_name_availability( self, resource_group_name: str, @@ -66,38 +71,34 @@ async def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CheckNameAvailability') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'CheckNameAvailability') + + request = build_check_name_availability_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) @@ -106,8 +107,11 @@ async def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability"} # type: ignore + + + @distributed_trace def list( self, resource_group_name: str, @@ -121,45 +125,48 @@ def list( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ArmDisasterRecoveryListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.ArmDisasterRecoveryListResult] + :return: An iterator like instance of either ArmDisasterRecoveryListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.ArmDisasterRecoveryListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ArmDisasterRecoveryListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ArmDisasterRecoveryListResult', pipeline_response) + deserialized = self._deserialize("ArmDisasterRecoveryListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -168,21 +175,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs"} # type: ignore + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -211,39 +224,35 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ArmDisasterRecovery') - 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) + + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ArmDisasterRecovery') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -254,9 +263,12 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}'} # type: ignore - async def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -281,41 +293,40 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -341,34 +352,31 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) @@ -377,9 +385,12 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}'} # type: ignore - async def break_pairing( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore + + + @distributed_trace_async + async def break_pairing( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -405,42 +416,41 @@ async def break_pairing( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.break_pairing.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_break_pairing_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.break_pairing.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - break_pairing.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing'} # type: ignore + break_pairing.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing"} # type: ignore - async def fail_over( + + @distributed_trace_async + async def fail_over( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -457,6 +467,7 @@ async def fail_over( :param alias: The Disaster Recovery configuration name. :type alias: str :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Default value is None. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.FailoverProperties :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) @@ -468,49 +479,47 @@ async def fail_over( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.fail_over.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if parameters is not None: - body_content = self._serialize.body(parameters, 'FailoverProperties') + _json = self._serialize.body(parameters, 'FailoverProperties') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + _json = None + + request = build_fail_over_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.fail_over.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - fail_over.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover'} # type: ignore + fail_over.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover"} # type: ignore + + @distributed_trace def list_authorization_rules( self, resource_group_name: str, @@ -527,46 +536,50 @@ def list_authorization_rules( :param alias: The Disaster Recovery configuration name. :type alias: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRuleListResult] + :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SBAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -575,21 +588,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules"} # type: ignore + @distributed_trace_async async def get_authorization_rule( self, resource_group_name: str, @@ -618,35 +637,32 @@ async def get_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -655,8 +671,11 @@ async def get_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}'} # type: ignore + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace_async async def list_keys( self, resource_group_name: str, @@ -685,35 +704,32 @@ async def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -722,4 +738,6 @@ async def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys'} # type: ignore + + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_migration_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_migration_configs_operations.py index d409df541cfa..98a3c6f03041 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_migration_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_migration_configs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,19 +6,22 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._migration_configs_operations import build_complete_migration_request, build_create_and_start_migration_request_initial, build_delete_request, build_get_request, build_list_request, build_revert_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +47,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name: str, @@ -56,45 +61,48 @@ def list( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MigrationConfigListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigListResult] + :return: An iterator like instance of either MigrationConfigListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.MigrationConfigListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('MigrationConfigListResult', pipeline_response) + deserialized = self._deserialize("MigrationConfigListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,20 +111,25 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations"} # type: ignore async def _create_and_start_migration_initial( self, @@ -131,40 +144,35 @@ async def _create_and_start_migration_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_and_start_migration_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'MigrationConfigProperties') - 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) + + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'MigrationConfigProperties') + + request = build_create_and_start_migration_request_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_and_start_migration_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -174,8 +182,11 @@ async def _create_and_start_migration_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_and_start_migration_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}'} # type: ignore + _create_and_start_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + + + @distributed_trace_async async def begin_create_and_start_migration( self, resource_group_name: str, @@ -192,19 +203,26 @@ async def begin_create_and_start_migration( :param namespace_name: The namespace name. :type namespace_name: str :param config_name: The configuration name. Should always be "$default". - :type config_name: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigurationName + :type config_name: str or + ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigurationName :param parameters: Parameters required to create Migration Configuration. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigProperties :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either MigrationConfigProperties or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigProperties] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MigrationConfigProperties or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigProperties] + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.MigrationConfigProperties"] lro_delay = kwargs.pop( @@ -218,28 +236,22 @@ async def begin_create_and_start_migration( namespace_name=namespace_name, config_name=config_name, parameters=parameters, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -249,11 +261,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_and_start_migration.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_and_start_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore - async def delete( + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -267,7 +280,8 @@ async def delete( :param namespace_name: The namespace name. :type namespace_name: str :param config_name: The configuration name. Should always be "$default". - :type config_name: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigurationName + :type config_name: str or + ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigurationName :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -278,41 +292,40 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -327,7 +340,8 @@ async def get( :param namespace_name: The namespace name. :type namespace_name: str :param config_name: The configuration name. Should always be "$default". - :type config_name: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigurationName + :type config_name: str or + ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigurationName :keyword callable cls: A custom type or function that will be passed the direct response :return: MigrationConfigProperties, or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigProperties @@ -338,34 +352,31 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) @@ -374,9 +385,12 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}'} # type: ignore - async def complete_migration( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + + + @distributed_trace_async + async def complete_migration( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -392,7 +406,8 @@ async def complete_migration( :param namespace_name: The namespace name. :type namespace_name: str :param config_name: The configuration name. Should always be "$default". - :type config_name: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigurationName + :type config_name: str or + ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigurationName :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -403,42 +418,41 @@ async def complete_migration( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.complete_migration.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_complete_migration_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.complete_migration.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - complete_migration.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade'} # type: ignore + complete_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade"} # type: ignore - async def revert( + + @distributed_trace_async + async def revert( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -452,7 +466,8 @@ async def revert( :param namespace_name: The namespace name. :type namespace_name: str :param config_name: The configuration name. Should always be "$default". - :type config_name: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigurationName + :type config_name: str or + ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigurationName :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -463,37 +478,35 @@ async def revert( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.revert.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_revert_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.revert.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - revert.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert'} # type: ignore + revert.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_namespaces_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_namespaces_operations.py index 9b50088c31ec..27e94d795963 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_namespaces_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_namespaces_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,19 +6,22 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._namespaces_operations import build_check_name_availability_request, build_create_or_update_authorization_rule_request, build_create_or_update_network_rule_set_request, build_create_or_update_request_initial, build_delete_authorization_rule_request, build_delete_request_initial, build_get_authorization_rule_request, build_get_network_rule_set_request, build_get_request, build_list_authorization_rules_request, build_list_by_resource_group_request, build_list_keys_request, build_list_network_rule_sets_request, build_list_request, build_regenerate_keys_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +47,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -50,43 +55,44 @@ def list( """Gets all the available namespaces within the subscription, irrespective of the resource groups. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBNamespaceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespaceListResult] + :return: An iterator like instance of either SBNamespaceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespaceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBNamespaceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SBNamespaceListResult', pipeline_response) + deserialized = self._deserialize("SBNamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -95,21 +101,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces"} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -120,44 +132,46 @@ def list_by_resource_group( :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBNamespaceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespaceListResult] + :return: An iterator like instance of either SBNamespaceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespaceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBNamespaceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SBNamespaceListResult', pipeline_response) + deserialized = self._deserialize("SBNamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -166,20 +180,25 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces"} # type: ignore async def _create_or_update_initial( self, @@ -193,39 +212,34 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBNamespace') - 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) + + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBNamespace') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -238,8 +252,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -258,14 +275,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either SBNamespace or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either SBNamespace or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace] + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.SBNamespace"] lro_delay = kwargs.pop( @@ -278,27 +301,22 @@ async def begin_create_or_update( resource_group_name=resource_group_name, namespace_name=namespace_name, parameters=parameters, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('SBNamespace', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -308,11 +326,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - async def _delete_initial( + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -323,41 +341,39 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - async def begin_delete( + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -372,14 +388,17 @@ async def begin_delete( :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( @@ -391,24 +410,18 @@ async def begin_delete( raw_result = await self._delete_initial( resource_group_name=resource_group_name, namespace_name=namespace_name, + api_version=api_version, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -418,10 +431,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -444,33 +458,30 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBNamespace', pipeline_response) @@ -479,8 +490,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -507,38 +521,34 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -552,8 +562,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + + @distributed_trace_async async def create_or_update_network_rule_set( self, resource_group_name: str, @@ -579,38 +592,34 @@ async def create_or_update_network_rule_set( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_network_rule_set.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'NetworkRuleSet') - 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) + + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'NetworkRuleSet') + + request = build_create_or_update_network_rule_set_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_network_rule_set.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('NetworkRuleSet', pipeline_response) @@ -619,8 +628,11 @@ async def create_or_update_network_rule_set( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_network_rule_set.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default'} # type: ignore + create_or_update_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore + + + @distributed_trace_async async def get_network_rule_set( self, resource_group_name: str, @@ -643,33 +655,30 @@ async def get_network_rule_set( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_network_rule_set.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_network_rule_set_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_network_rule_set.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('NetworkRuleSet', pipeline_response) @@ -678,8 +687,11 @@ async def get_network_rule_set( return cls(pipeline_response, deserialized, {}) return deserialized - get_network_rule_set.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default'} # type: ignore + get_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore + + + @distributed_trace def list_network_rule_sets( self, resource_group_name: str, @@ -693,45 +705,48 @@ def list_network_rule_sets( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NetworkRuleSetListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleSetListResult] + :return: An iterator like instance of either NetworkRuleSetListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkRuleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_network_rule_sets.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_network_rule_sets_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_network_rule_sets.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_network_rule_sets_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('NetworkRuleSetListResult', pipeline_response) + deserialized = self._deserialize("NetworkRuleSetListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -740,21 +755,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_network_rule_sets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets'} # type: ignore + list_network_rule_sets.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets"} # type: ignore + @distributed_trace def list_authorization_rules( self, resource_group_name: str, @@ -768,45 +789,48 @@ def list_authorization_rules( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRuleListResult] + :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SBAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -815,21 +839,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules"} # type: ignore + @distributed_trace_async async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -858,39 +888,35 @@ async def create_or_update_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBAuthorizationRule') - 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) + + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBAuthorizationRule') + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -899,9 +925,12 @@ async def create_or_update_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}'} # type: ignore - async def delete_authorization_rule( + create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace_async + async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -926,41 +955,40 @@ async def delete_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}'} # type: ignore + delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore + + @distributed_trace_async async def get_authorization_rule( self, resource_group_name: str, @@ -986,34 +1014,31 @@ async def get_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -1022,8 +1047,11 @@ async def get_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}'} # type: ignore + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace_async async def list_keys( self, resource_group_name: str, @@ -1049,34 +1077,31 @@ async def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -1085,8 +1110,11 @@ async def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore + + + @distributed_trace_async async def regenerate_keys( self, resource_group_name: str, @@ -1104,7 +1132,8 @@ async def regenerate_keys( :param authorization_rule_name: The authorization rule name. :type authorization_rule_name: str :param parameters: Parameters supplied to regenerate the authorization rule. - :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.RegenerateAccessKeyParameters + :type parameters: + ~azure.mgmt.servicebus.v2021_06_01_preview.models.RegenerateAccessKeyParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessKeys, or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys @@ -1115,39 +1144,35 @@ async def regenerate_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -1156,8 +1181,11 @@ async def regenerate_keys( return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys'} # type: ignore + regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + + + @distributed_trace_async async def check_name_availability( self, parameters: "_models.CheckNameAvailability", @@ -1177,36 +1205,32 @@ async def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CheckNameAvailability') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'CheckNameAvailability') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) @@ -1215,4 +1239,6 @@ async def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability'} # type: ignore + + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_operations.py index 10e984942d59..42d250b20c2d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,19 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,38 +53,40 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -89,17 +95,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.ServiceBus/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.ServiceBus/operations"} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_private_endpoint_connections_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_private_endpoint_connections_operations.py index 534fce7b9059..511d2c0ce586 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_private_endpoint_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,19 +6,22 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._private_endpoint_connections_operations import build_create_or_update_request, build_delete_request_initial, build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +47,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name: str, @@ -56,45 +61,48 @@ def list( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateEndpointConnectionListResult] + :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PrivateEndpointConnectionListResult', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,21 +111,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections"} # type: ignore + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -147,39 +161,35 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PrivateEndpointConnection') - 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) + + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + namespace_name=namespace_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -192,9 +202,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - async def _delete_initial( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -206,42 +218,40 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + - async def begin_delete( + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -258,14 +268,17 @@ async def begin_delete( :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( @@ -278,25 +291,18 @@ async def begin_delete( resource_group_name=resource_group_name, namespace_name=namespace_name, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -306,10 +312,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -335,34 +342,31 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) @@ -371,4 +375,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_private_link_resources_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_private_link_resources_operations.py index 4888455be029..0ae2bc0d52e2 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_private_link_resources_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_private_link_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,16 +6,18 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._private_link_resources_operations import build_get_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +43,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -62,33 +66,30 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PrivateLinkResourcesListResult', pipeline_response) @@ -97,4 +98,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_queues_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_queues_operations.py index 5a8d54467ec6..f82b7419be79 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_queues_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_queues_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._queues_operations import build_create_or_update_authorization_rule_request, build_create_or_update_request, build_delete_authorization_rule_request, build_delete_request, build_get_authorization_rule_request, build_get_request, build_list_authorization_rules_request, build_list_by_namespace_request, build_list_keys_request, build_regenerate_keys_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_authorization_rules( self, resource_group_name: str, @@ -57,46 +62,50 @@ def list_authorization_rules( :param queue_name: The queue name. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRuleListResult] + :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SBAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,21 +114,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules"} # type: ignore + @distributed_trace_async async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -151,40 +166,36 @@ async def create_or_update_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBAuthorizationRule') - 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) + + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBAuthorizationRule') + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -193,9 +204,12 @@ async def create_or_update_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}'} # type: ignore - async def delete_authorization_rule( + create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace_async + async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -223,42 +237,41 @@ async def delete_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}'} # type: ignore + delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + @distributed_trace_async async def get_authorization_rule( self, resource_group_name: str, @@ -287,35 +300,32 @@ async def get_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -324,8 +334,11 @@ async def get_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}'} # type: ignore + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace_async async def list_keys( self, resource_group_name: str, @@ -354,35 +367,32 @@ async def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -391,8 +401,11 @@ async def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore + + + @distributed_trace_async async def regenerate_keys( self, resource_group_name: str, @@ -413,7 +426,8 @@ async def regenerate_keys( :param authorization_rule_name: The authorization rule name. :type authorization_rule_name: str :param parameters: Parameters supplied to regenerate the authorization rule. - :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.RegenerateAccessKeyParameters + :type parameters: + ~azure.mgmt.servicebus.v2021_06_01_preview.models.RegenerateAccessKeyParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessKeys, or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys @@ -424,40 +438,36 @@ async def regenerate_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -466,8 +476,11 @@ async def regenerate_keys( return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys'} # type: ignore + regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + + + @distributed_trace def list_by_namespace( self, resource_group_name: str, @@ -484,54 +497,57 @@ def list_by_namespace( :type namespace_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. + parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip: int :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SBQueueListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBQueueListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBQueueListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBQueueListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_namespace.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', maximum=1000, minimum=0) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=self.list_by_namespace.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SBQueueListResult', pipeline_response) + deserialized = self._deserialize("SBQueueListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -540,21 +556,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_namespace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues'} # type: ignore + list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues"} # type: ignore + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -583,39 +605,35 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBQueue') - 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) + + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBQueue') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBQueue', pipeline_response) @@ -624,9 +642,12 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}'} # type: ignore - async def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -651,41 +672,40 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -711,34 +731,31 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBQueue', pipeline_response) @@ -747,4 +764,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_rules_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_rules_operations.py index ee3b32d993b1..09329270fb89 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_rules_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_rules_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._rules_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_subscriptions_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_subscriptions( self, resource_group_name: str, @@ -63,56 +68,61 @@ def list_by_subscriptions( :type subscription_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. + parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip: int :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.RuleListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.RuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscriptions.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', maximum=1000, minimum=0) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscriptions_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=self.list_by_subscriptions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscriptions_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RuleListResult', pipeline_response) + deserialized = self._deserialize("RuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -121,21 +131,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_subscriptions.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules'} # type: ignore + list_by_subscriptions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules"} # type: ignore + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -170,41 +186,37 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Rule') - 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) + + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Rule') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Rule', pipeline_response) @@ -213,9 +225,12 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}'} # type: ignore - async def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -246,43 +261,42 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -314,36 +328,33 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Rule', pipeline_response) @@ -352,4 +363,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_subscriptions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_subscriptions_operations.py index feddfec1b736..03a99d3100be 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_subscriptions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_subscriptions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._subscriptions_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_topic_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_topic( self, resource_group_name: str, @@ -60,55 +65,60 @@ def list_by_topic( :type topic_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. + parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip: int :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBSubscriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSubscriptionListResult] + :return: An iterator like instance of either SBSubscriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSubscriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBSubscriptionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_topic.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', maximum=1000, minimum=0) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_topic_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=self.list_by_topic.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_topic_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SBSubscriptionListResult', pipeline_response) + deserialized = self._deserialize("SBSubscriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -117,21 +127,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_topic.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions'} # type: ignore + list_by_topic.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions"} # type: ignore + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -163,40 +179,36 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBSubscription') - 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) + + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBSubscription') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBSubscription', pipeline_response) @@ -205,9 +217,12 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}'} # type: ignore - async def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -235,42 +250,41 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -299,35 +313,32 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBSubscription', pipeline_response) @@ -336,4 +347,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_topics_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_topics_operations.py index b4e7cbe848bf..7d8fe7c59cc5 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_topics_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_topics_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._topics_operations import build_create_or_update_authorization_rule_request, build_create_or_update_request, build_delete_authorization_rule_request, build_delete_request, build_get_authorization_rule_request, build_get_request, build_list_authorization_rules_request, build_list_by_namespace_request, build_list_keys_request, build_regenerate_keys_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_authorization_rules( self, resource_group_name: str, @@ -57,46 +62,50 @@ def list_authorization_rules( :param topic_name: The topic name. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRuleListResult] + :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SBAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,21 +114,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules"} # type: ignore + @distributed_trace_async async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -151,40 +166,36 @@ async def create_or_update_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBAuthorizationRule') - 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) + + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBAuthorizationRule') + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -193,8 +204,11 @@ async def create_or_update_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}'} # type: ignore + create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace_async async def get_authorization_rule( self, resource_group_name: str, @@ -223,35 +237,32 @@ async def get_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -260,9 +271,12 @@ async def get_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}'} # type: ignore - async def delete_authorization_rule( + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace_async + async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -290,42 +304,41 @@ async def delete_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}'} # type: ignore + delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + @distributed_trace_async async def list_keys( self, resource_group_name: str, @@ -354,35 +367,32 @@ async def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -391,8 +401,11 @@ async def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore + + + @distributed_trace_async async def regenerate_keys( self, resource_group_name: str, @@ -413,7 +426,8 @@ async def regenerate_keys( :param authorization_rule_name: The authorization rule name. :type authorization_rule_name: str :param parameters: Parameters supplied to regenerate the authorization rule. - :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.RegenerateAccessKeyParameters + :type parameters: + ~azure.mgmt.servicebus.v2021_06_01_preview.models.RegenerateAccessKeyParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessKeys, or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys @@ -424,40 +438,36 @@ async def regenerate_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -466,8 +476,11 @@ async def regenerate_keys( return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys'} # type: ignore + regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + + + @distributed_trace def list_by_namespace( self, resource_group_name: str, @@ -484,54 +497,57 @@ def list_by_namespace( :type namespace_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. + parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip: int :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SBTopicListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBTopicListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBTopicListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBTopicListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_namespace.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', maximum=1000, minimum=0) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=self.list_by_namespace.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SBTopicListResult', pipeline_response) + deserialized = self._deserialize("SBTopicListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -540,21 +556,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_namespace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics'} # type: ignore + list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics"} # type: ignore + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -583,39 +605,35 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBTopic') - 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) + + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBTopic') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBTopic', pipeline_response) @@ -624,9 +642,12 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}'} # type: ignore - async def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -651,41 +672,40 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -711,34 +731,31 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBTopic', pipeline_response) @@ -747,4 +764,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/models/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/models/__init__.py index 24c95ad251e9..b18a0bc44edf 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/models/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/models/__init__.py @@ -6,118 +6,62 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import AccessKeys - from ._models_py3 import Action - from ._models_py3 import ArmDisasterRecovery - from ._models_py3 import ArmDisasterRecoveryListResult - from ._models_py3 import CheckNameAvailability - from ._models_py3 import CheckNameAvailabilityResult - from ._models_py3 import ConnectionState - from ._models_py3 import CorrelationFilter - from ._models_py3 import Encryption - from ._models_py3 import ErrorAdditionalInfo - from ._models_py3 import ErrorResponse - from ._models_py3 import ErrorResponseError - from ._models_py3 import FailoverProperties - from ._models_py3 import Identity - from ._models_py3 import KeyVaultProperties - from ._models_py3 import MessageCountDetails - from ._models_py3 import MigrationConfigListResult - from ._models_py3 import MigrationConfigProperties - from ._models_py3 import NWRuleSetIpRules - from ._models_py3 import NWRuleSetVirtualNetworkRules - from ._models_py3 import NetworkRuleSet - from ._models_py3 import NetworkRuleSetListResult - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationListResult - from ._models_py3 import PrivateEndpoint - from ._models_py3 import PrivateEndpointConnection - from ._models_py3 import PrivateEndpointConnectionListResult - from ._models_py3 import PrivateLinkResource - from ._models_py3 import PrivateLinkResourcesListResult - from ._models_py3 import RegenerateAccessKeyParameters - from ._models_py3 import Resource - from ._models_py3 import ResourceNamespacePatch - from ._models_py3 import Rule - from ._models_py3 import RuleListResult - from ._models_py3 import SBAuthorizationRule - from ._models_py3 import SBAuthorizationRuleListResult - from ._models_py3 import SBClientAffineProperties - from ._models_py3 import SBNamespace - from ._models_py3 import SBNamespaceListResult - from ._models_py3 import SBNamespaceUpdateParameters - from ._models_py3 import SBQueue - from ._models_py3 import SBQueueListResult - from ._models_py3 import SBSku - from ._models_py3 import SBSubscription - from ._models_py3 import SBSubscriptionListResult - from ._models_py3 import SBTopic - from ._models_py3 import SBTopicListResult - from ._models_py3 import SqlFilter - from ._models_py3 import SqlRuleAction - from ._models_py3 import Subnet - from ._models_py3 import SystemData - from ._models_py3 import TrackedResource - from ._models_py3 import UserAssignedIdentity - from ._models_py3 import UserAssignedIdentityProperties -except (SyntaxError, ImportError): - from ._models import AccessKeys # type: ignore - from ._models import Action # type: ignore - from ._models import ArmDisasterRecovery # type: ignore - from ._models import ArmDisasterRecoveryListResult # type: ignore - from ._models import CheckNameAvailability # type: ignore - from ._models import CheckNameAvailabilityResult # type: ignore - from ._models import ConnectionState # type: ignore - from ._models import CorrelationFilter # type: ignore - from ._models import Encryption # type: ignore - from ._models import ErrorAdditionalInfo # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import ErrorResponseError # type: ignore - from ._models import FailoverProperties # type: ignore - from ._models import Identity # type: ignore - from ._models import KeyVaultProperties # type: ignore - from ._models import MessageCountDetails # type: ignore - from ._models import MigrationConfigListResult # type: ignore - from ._models import MigrationConfigProperties # type: ignore - from ._models import NWRuleSetIpRules # type: ignore - from ._models import NWRuleSetVirtualNetworkRules # type: ignore - from ._models import NetworkRuleSet # type: ignore - from ._models import NetworkRuleSetListResult # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import PrivateEndpoint # type: ignore - from ._models import PrivateEndpointConnection # type: ignore - from ._models import PrivateEndpointConnectionListResult # type: ignore - from ._models import PrivateLinkResource # type: ignore - from ._models import PrivateLinkResourcesListResult # type: ignore - from ._models import RegenerateAccessKeyParameters # type: ignore - from ._models import Resource # type: ignore - from ._models import ResourceNamespacePatch # type: ignore - from ._models import Rule # type: ignore - from ._models import RuleListResult # type: ignore - from ._models import SBAuthorizationRule # type: ignore - from ._models import SBAuthorizationRuleListResult # type: ignore - from ._models import SBClientAffineProperties # type: ignore - from ._models import SBNamespace # type: ignore - from ._models import SBNamespaceListResult # type: ignore - from ._models import SBNamespaceUpdateParameters # type: ignore - from ._models import SBQueue # type: ignore - from ._models import SBQueueListResult # type: ignore - from ._models import SBSku # type: ignore - from ._models import SBSubscription # type: ignore - from ._models import SBSubscriptionListResult # type: ignore - from ._models import SBTopic # type: ignore - from ._models import SBTopicListResult # type: ignore - from ._models import SqlFilter # type: ignore - from ._models import SqlRuleAction # type: ignore - from ._models import Subnet # type: ignore - from ._models import SystemData # type: ignore - from ._models import TrackedResource # type: ignore - from ._models import UserAssignedIdentity # type: ignore - from ._models import UserAssignedIdentityProperties # type: ignore +from ._models_py3 import AccessKeys +from ._models_py3 import Action +from ._models_py3 import ArmDisasterRecovery +from ._models_py3 import ArmDisasterRecoveryListResult +from ._models_py3 import CheckNameAvailability +from ._models_py3 import CheckNameAvailabilityResult +from ._models_py3 import ConnectionState +from ._models_py3 import CorrelationFilter +from ._models_py3 import Encryption +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorResponse +from ._models_py3 import ErrorResponseError +from ._models_py3 import FailoverProperties +from ._models_py3 import Identity +from ._models_py3 import KeyVaultProperties +from ._models_py3 import MessageCountDetails +from ._models_py3 import MigrationConfigListResult +from ._models_py3 import MigrationConfigProperties +from ._models_py3 import NWRuleSetIpRules +from ._models_py3 import NWRuleSetVirtualNetworkRules +from ._models_py3 import NetworkRuleSet +from ._models_py3 import NetworkRuleSetListResult +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import PrivateEndpoint +from ._models_py3 import PrivateEndpointConnection +from ._models_py3 import PrivateEndpointConnectionListResult +from ._models_py3 import PrivateLinkResource +from ._models_py3 import PrivateLinkResourcesListResult +from ._models_py3 import RegenerateAccessKeyParameters +from ._models_py3 import Resource +from ._models_py3 import ResourceNamespacePatch +from ._models_py3 import Rule +from ._models_py3 import RuleListResult +from ._models_py3 import SBAuthorizationRule +from ._models_py3 import SBAuthorizationRuleListResult +from ._models_py3 import SBClientAffineProperties +from ._models_py3 import SBNamespace +from ._models_py3 import SBNamespaceListResult +from ._models_py3 import SBNamespaceUpdateParameters +from ._models_py3 import SBQueue +from ._models_py3 import SBQueueListResult +from ._models_py3 import SBSku +from ._models_py3 import SBSubscription +from ._models_py3 import SBSubscriptionListResult +from ._models_py3 import SBTopic +from ._models_py3 import SBTopicListResult +from ._models_py3 import SqlFilter +from ._models_py3 import SqlRuleAction +from ._models_py3 import Subnet +from ._models_py3 import SystemData +from ._models_py3 import TrackedResource +from ._models_py3 import UserAssignedIdentity +from ._models_py3 import UserAssignedIdentityProperties + from ._service_bus_management_client_enums import ( AccessRights, diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/models/_models.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/models/_models.py deleted file mode 100644 index 7bd466e9beb9..000000000000 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/models/_models.py +++ /dev/null @@ -1,2306 +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 azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class AccessKeys(msrest.serialization.Model): - """Namespace/ServiceBus Connection String. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar primary_connection_string: Primary connection string of the created namespace - authorization rule. - :vartype primary_connection_string: str - :ivar secondary_connection_string: Secondary connection string of the created namespace - authorization rule. - :vartype secondary_connection_string: str - :ivar alias_primary_connection_string: Primary connection string of the alias if GEO DR is - enabled. - :vartype alias_primary_connection_string: str - :ivar alias_secondary_connection_string: Secondary connection string of the alias if GEO DR is - enabled. - :vartype alias_secondary_connection_string: str - :ivar primary_key: A base64-encoded 256-bit primary key for signing and validating the SAS - token. - :vartype primary_key: str - :ivar secondary_key: A base64-encoded 256-bit primary key for signing and validating the SAS - token. - :vartype secondary_key: str - :ivar key_name: A string that describes the authorization rule. - :vartype key_name: str - """ - - _validation = { - 'primary_connection_string': {'readonly': True}, - 'secondary_connection_string': {'readonly': True}, - 'alias_primary_connection_string': {'readonly': True}, - 'alias_secondary_connection_string': {'readonly': True}, - 'primary_key': {'readonly': True}, - 'secondary_key': {'readonly': True}, - 'key_name': {'readonly': True}, - } - - _attribute_map = { - 'primary_connection_string': {'key': 'primaryConnectionString', 'type': 'str'}, - 'secondary_connection_string': {'key': 'secondaryConnectionString', 'type': 'str'}, - 'alias_primary_connection_string': {'key': 'aliasPrimaryConnectionString', 'type': 'str'}, - 'alias_secondary_connection_string': {'key': 'aliasSecondaryConnectionString', 'type': 'str'}, - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, - 'key_name': {'key': 'keyName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AccessKeys, self).__init__(**kwargs) - self.primary_connection_string = None - self.secondary_connection_string = None - self.alias_primary_connection_string = None - self.alias_secondary_connection_string = None - self.primary_key = None - self.secondary_key = None - self.key_name = None - - -class Action(msrest.serialization.Model): - """Represents the filter actions which are allowed for the transformation of a message that have been matched by a filter expression. - - :param sql_expression: SQL expression. e.g. MyProperty='ABC'. - :type sql_expression: str - :param compatibility_level: This property is reserved for future use. An integer value showing - the compatibility level, currently hard-coded to 20. - :type compatibility_level: int - :param requires_preprocessing: Value that indicates whether the rule action requires - preprocessing. - :type requires_preprocessing: bool - """ - - _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(Action, self).__init__(**kwargs) - self.sql_expression = kwargs.get('sql_expression', None) - self.compatibility_level = kwargs.get('compatibility_level', None) - self.requires_preprocessing = kwargs.get('requires_preprocessing', True) - - -class Resource(msrest.serialization.Model): - """The Resource definition for other than namespace. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class ArmDisasterRecovery(Resource): - """Single item in List or Get Alias(Disaster Recovery configuration) operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SystemData - :ivar provisioning_state: Provisioning state of the Alias(Disaster Recovery configuration) - - possible values 'Accepted' or 'Succeeded' or 'Failed'. Possible values include: "Accepted", - "Succeeded", "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.servicebus.v2021_06_01_preview.models.ProvisioningStateDR - :ivar pending_replication_operations_count: Number of entities pending to be replicated. - :vartype pending_replication_operations_count: long - :param partner_namespace: ARM Id of the Primary/Secondary eventhub namespace name, which is - part of GEO DR pairing. - :type partner_namespace: str - :param alternate_name: Primary/Secondary eventhub namespace name, which is part of GEO DR - pairing. - :type alternate_name: str - :ivar role: role of namespace in GEO DR - possible values 'Primary' or 'PrimaryNotReplicating' - or 'Secondary'. Possible values include: "Primary", "PrimaryNotReplicating", "Secondary". - :vartype role: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.RoleDisasterRecovery - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'pending_replication_operations_count': {'readonly': True}, - 'role': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'pending_replication_operations_count': {'key': 'properties.pendingReplicationOperationsCount', 'type': 'long'}, - 'partner_namespace': {'key': 'properties.partnerNamespace', 'type': 'str'}, - 'alternate_name': {'key': 'properties.alternateName', 'type': 'str'}, - 'role': {'key': 'properties.role', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ArmDisasterRecovery, self).__init__(**kwargs) - self.system_data = None - self.provisioning_state = None - self.pending_replication_operations_count = None - self.partner_namespace = kwargs.get('partner_namespace', None) - self.alternate_name = kwargs.get('alternate_name', None) - self.role = None - - -class ArmDisasterRecoveryListResult(msrest.serialization.Model): - """The result of the List Alias(Disaster Recovery configuration) operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: List of Alias(Disaster Recovery configurations). - :type value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.ArmDisasterRecovery] - :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list - of Alias(Disaster Recovery configuration). - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ArmDisasterRecovery]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ArmDisasterRecoveryListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class CheckNameAvailability(msrest.serialization.Model): - """Description of a Check Name availability request properties. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The Name to check the namespace name availability and The namespace name - can contain only letters, numbers, and hyphens. The namespace must start with a letter, and it - must end with a letter or number. - :type name: str - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CheckNameAvailability, self).__init__(**kwargs) - self.name = kwargs['name'] - - -class CheckNameAvailabilityResult(msrest.serialization.Model): - """Description of a Check Name availability request properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar message: The detailed info regarding the reason associated with the namespace. - :vartype message: str - :param name_available: Value indicating namespace is availability, true if the namespace is - available; otherwise, false. - :type name_available: bool - :param reason: The reason for unavailability of a namespace. Possible values include: "None", - "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", - "TooManyNamespaceInCurrentSubscription". - :type reason: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.UnavailableReason - """ - - _validation = { - 'message': {'readonly': True}, - } - - _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CheckNameAvailabilityResult, self).__init__(**kwargs) - self.message = None - self.name_available = kwargs.get('name_available', None) - self.reason = kwargs.get('reason', None) - - -class ConnectionState(msrest.serialization.Model): - """ConnectionState information. - - :param status: Status of the connection. Possible values include: "Pending", "Approved", - "Rejected", "Disconnected". - :type status: str or - ~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateLinkConnectionStatus - :param description: Description of the connection state. - :type description: str - """ - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ConnectionState, self).__init__(**kwargs) - self.status = kwargs.get('status', None) - self.description = kwargs.get('description', None) - - -class CorrelationFilter(msrest.serialization.Model): - """Represents the correlation filter expression. - - :param properties: dictionary object for custom filters. - :type properties: dict[str, str] - :param correlation_id: Identifier of the correlation. - :type correlation_id: str - :param message_id: Identifier of the message. - :type message_id: str - :param to: Address to send to. - :type to: str - :param reply_to: Address of the queue to reply to. - :type reply_to: str - :param label: Application specific label. - :type label: str - :param session_id: Session identifier. - :type session_id: str - :param reply_to_session_id: Session identifier to reply to. - :type reply_to_session_id: str - :param content_type: Content type of the message. - :type content_type: str - :param requires_preprocessing: Value that indicates whether the rule action requires - preprocessing. - :type requires_preprocessing: bool - """ - - _attribute_map = { - 'properties': {'key': 'properties', 'type': '{str}'}, - 'correlation_id': {'key': 'correlationId', 'type': 'str'}, - 'message_id': {'key': 'messageId', 'type': 'str'}, - 'to': {'key': 'to', 'type': 'str'}, - 'reply_to': {'key': 'replyTo', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'session_id': {'key': 'sessionId', 'type': 'str'}, - 'reply_to_session_id': {'key': 'replyToSessionId', 'type': 'str'}, - 'content_type': {'key': 'contentType', 'type': 'str'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(CorrelationFilter, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - 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.requires_preprocessing = kwargs.get('requires_preprocessing', True) - - -class Encryption(msrest.serialization.Model): - """Properties to configure Encryption. - - :param key_vault_properties: Properties of KeyVault. - :type key_vault_properties: - list[~azure.mgmt.servicebus.v2021_06_01_preview.models.KeyVaultProperties] - :param key_source: Enumerates the possible value of keySource for Encryption. The only - acceptable values to pass in are None and "Microsoft.KeyVault". The default value is - "Microsoft.KeyVault". - :type key_source: str - :param require_infrastructure_encryption: Enable Infrastructure Encryption (Double Encryption). - :type require_infrastructure_encryption: bool - """ - - _attribute_map = { - 'key_vault_properties': {'key': 'keyVaultProperties', 'type': '[KeyVaultProperties]'}, - 'key_source': {'key': 'keySource', 'type': 'str'}, - 'require_infrastructure_encryption': {'key': 'requireInfrastructureEncryption', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(Encryption, self).__init__(**kwargs) - self.key_vault_properties = kwargs.get('key_vault_properties', None) - self.key_source = kwargs.get('key_source', "Microsoft.KeyVault") - self.require_infrastructure_encryption = kwargs.get('require_infrastructure_encryption', None) - - -class ErrorAdditionalInfo(msrest.serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: any - """ - - _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorAdditionalInfo, self).__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorResponse(msrest.serialization.Model): - """The resource management error response. - - :param error: The error object. - :type error: ~azure.mgmt.servicebus.v2021_06_01_preview.models.ErrorResponseError - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseError'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class ErrorResponseError(msrest.serialization.Model): - """The error object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.ErrorResponse] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.servicebus.v2021_06_01_preview.models.ErrorAdditionalInfo] - """ - - _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponseError, self).__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class FailoverProperties(msrest.serialization.Model): - """Safe failover is to indicate the service should wait for pending replication to finish before switching to the secondary. - - :param is_safe_failover: Safe failover is to indicate the service should wait for pending - replication to finish before switching to the secondary. - :type is_safe_failover: bool - """ - - _attribute_map = { - 'is_safe_failover': {'key': 'properties.IsSafeFailover', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(FailoverProperties, self).__init__(**kwargs) - self.is_safe_failover = kwargs.get('is_safe_failover', None) - - -class Identity(msrest.serialization.Model): - """Properties to configure User Assigned Identities for Bring your Own Keys. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: ObjectId from the KeyVault. - :vartype principal_id: str - :ivar tenant_id: TenantId from the KeyVault. - :vartype tenant_id: str - :param type: Type of managed service identity. Possible values include: "SystemAssigned", - "UserAssigned", "SystemAssigned, UserAssigned", "None". - :type type: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.ManagedServiceIdentityType - :param user_assigned_identities: Properties for User Assigned Identities. - :type user_assigned_identities: dict[str, - ~azure.mgmt.servicebus.v2021_06_01_preview.models.UserAssignedIdentity] - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserAssignedIdentity}'}, - } - - def __init__( - self, - **kwargs - ): - super(Identity, self).__init__(**kwargs) - self.principal_id = None - self.tenant_id = None - self.type = kwargs.get('type', None) - self.user_assigned_identities = kwargs.get('user_assigned_identities', None) - - -class KeyVaultProperties(msrest.serialization.Model): - """Properties to configure keyVault Properties. - - :param key_name: Name of the Key from KeyVault. - :type key_name: str - :param key_vault_uri: Uri of KeyVault. - :type key_vault_uri: str - :param key_version: Version of KeyVault. - :type key_version: str - :param identity: - :type identity: - ~azure.mgmt.servicebus.v2021_06_01_preview.models.UserAssignedIdentityProperties - """ - - _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'key_vault_uri': {'key': 'keyVaultUri', 'type': 'str'}, - 'key_version': {'key': 'keyVersion', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'UserAssignedIdentityProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(KeyVaultProperties, self).__init__(**kwargs) - self.key_name = kwargs.get('key_name', None) - self.key_vault_uri = kwargs.get('key_vault_uri', None) - self.key_version = kwargs.get('key_version', None) - self.identity = kwargs.get('identity', None) - - -class MessageCountDetails(msrest.serialization.Model): - """Message Count Details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar active_message_count: Number of active messages in the queue, topic, or subscription. - :vartype active_message_count: long - :ivar dead_letter_message_count: Number of messages that are dead lettered. - :vartype dead_letter_message_count: long - :ivar scheduled_message_count: Number of scheduled messages. - :vartype scheduled_message_count: long - :ivar transfer_message_count: Number of messages transferred to another queue, topic, or - subscription. - :vartype transfer_message_count: long - :ivar transfer_dead_letter_message_count: Number of messages transferred into dead letters. - :vartype transfer_dead_letter_message_count: long - """ - - _validation = { - 'active_message_count': {'readonly': True}, - 'dead_letter_message_count': {'readonly': True}, - 'scheduled_message_count': {'readonly': True}, - 'transfer_message_count': {'readonly': True}, - 'transfer_dead_letter_message_count': {'readonly': True}, - } - - _attribute_map = { - 'active_message_count': {'key': 'activeMessageCount', 'type': 'long'}, - 'dead_letter_message_count': {'key': 'deadLetterMessageCount', 'type': 'long'}, - 'scheduled_message_count': {'key': 'scheduledMessageCount', 'type': 'long'}, - 'transfer_message_count': {'key': 'transferMessageCount', 'type': 'long'}, - 'transfer_dead_letter_message_count': {'key': 'transferDeadLetterMessageCount', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(MessageCountDetails, self).__init__(**kwargs) - self.active_message_count = None - self.dead_letter_message_count = None - self.scheduled_message_count = None - self.transfer_message_count = None - self.transfer_dead_letter_message_count = None - - -class MigrationConfigListResult(msrest.serialization.Model): - """The result of the List migrationConfigurations operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: List of Migration Configs. - :type value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigProperties] - :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list - of migrationConfigurations. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[MigrationConfigProperties]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MigrationConfigListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class MigrationConfigProperties(Resource): - """Single item in List or Get Migration Config operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SystemData - :ivar provisioning_state: Provisioning state of Migration Configuration. - :vartype provisioning_state: str - :ivar pending_replication_operations_count: Number of entities pending to be replicated. - :vartype pending_replication_operations_count: long - :param target_namespace: Existing premium Namespace ARM Id name which has no entities, will be - used for migration. - :type target_namespace: str - :param post_migration_name: Name to access Standard Namespace after migration. - :type post_migration_name: str - :ivar migration_state: State in which Standard to Premium Migration is, possible values : - Unknown, Reverting, Completing, Initiating, Syncing, Active. - :vartype migration_state: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'pending_replication_operations_count': {'readonly': True}, - 'migration_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'pending_replication_operations_count': {'key': 'properties.pendingReplicationOperationsCount', 'type': 'long'}, - 'target_namespace': {'key': 'properties.targetNamespace', 'type': 'str'}, - 'post_migration_name': {'key': 'properties.postMigrationName', 'type': 'str'}, - 'migration_state': {'key': 'properties.migrationState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MigrationConfigProperties, self).__init__(**kwargs) - self.system_data = None - self.provisioning_state = None - self.pending_replication_operations_count = None - self.target_namespace = kwargs.get('target_namespace', None) - self.post_migration_name = kwargs.get('post_migration_name', None) - self.migration_state = None - - -class NetworkRuleSet(Resource): - """Description of NetworkRuleSet resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SystemData - :param trusted_service_access_enabled: Value that indicates whether Trusted Service Access is - Enabled or not. - :type trusted_service_access_enabled: bool - :param default_action: Default Action for Network Rule Set. Possible values include: "Allow", - "Deny". - :type default_action: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.DefaultAction - :param virtual_network_rules: List VirtualNetwork Rules. - :type virtual_network_rules: - list[~azure.mgmt.servicebus.v2021_06_01_preview.models.NWRuleSetVirtualNetworkRules] - :param ip_rules: List of IpRules. - :type ip_rules: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.NWRuleSetIpRules] - :param public_network_access: This determines if traffic is allowed over public network. By - default it is enabled. Possible values include: "Enabled", "Disabled". Default value: - "Enabled". - :type public_network_access: str or - ~azure.mgmt.servicebus.v2021_06_01_preview.models.PublicNetworkAccessFlag - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'trusted_service_access_enabled': {'key': 'properties.trustedServiceAccessEnabled', 'type': 'bool'}, - 'default_action': {'key': 'properties.defaultAction', 'type': 'str'}, - 'virtual_network_rules': {'key': 'properties.virtualNetworkRules', 'type': '[NWRuleSetVirtualNetworkRules]'}, - 'ip_rules': {'key': 'properties.ipRules', 'type': '[NWRuleSetIpRules]'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkRuleSet, self).__init__(**kwargs) - self.system_data = None - self.trusted_service_access_enabled = kwargs.get('trusted_service_access_enabled', None) - self.default_action = kwargs.get('default_action', None) - self.virtual_network_rules = kwargs.get('virtual_network_rules', None) - self.ip_rules = kwargs.get('ip_rules', None) - self.public_network_access = kwargs.get('public_network_access', "Enabled") - - -class NetworkRuleSetListResult(msrest.serialization.Model): - """The response of the List NetworkRuleSet operation. - - :param value: Result of the List NetworkRuleSet operation. - :type value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleSet] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list - of NetworkRuleSet. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[NetworkRuleSet]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkRuleSetListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class NWRuleSetIpRules(msrest.serialization.Model): - """Description of NetWorkRuleSet - IpRules resource. - - :param ip_mask: IP Mask. - :type ip_mask: str - :param action: The IP Filter Action. Possible values include: "Allow". Default value: "Allow". - :type action: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleIPAction - """ - - _attribute_map = { - 'ip_mask': {'key': 'ipMask', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NWRuleSetIpRules, self).__init__(**kwargs) - self.ip_mask = kwargs.get('ip_mask', None) - self.action = kwargs.get('action', "Allow") - - -class NWRuleSetVirtualNetworkRules(msrest.serialization.Model): - """Description of VirtualNetworkRules - NetworkRules resource. - - :param subnet: Subnet properties. - :type subnet: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Subnet - :param ignore_missing_vnet_service_endpoint: Value that indicates whether to ignore missing - VNet Service Endpoint. - :type ignore_missing_vnet_service_endpoint: bool - """ - - _attribute_map = { - 'subnet': {'key': 'subnet', 'type': 'Subnet'}, - 'ignore_missing_vnet_service_endpoint': {'key': 'ignoreMissingVnetServiceEndpoint', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(NWRuleSetVirtualNetworkRules, self).__init__(**kwargs) - self.subnet = kwargs.get('subnet', None) - self.ignore_missing_vnet_service_endpoint = kwargs.get('ignore_missing_vnet_service_endpoint', None) - - -class Operation(msrest.serialization.Model): - """A ServiceBus REST API operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Operation name: {provider}/{resource}/{operation}. - :vartype name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.servicebus.v2021_06_01_preview.models.OperationDisplay - """ - - _validation = { - 'name': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = None - self.display = kwargs.get('display', None) - - -class OperationDisplay(msrest.serialization.Model): - """The object that represents the operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provider: Service provider: Microsoft.ServiceBus. - :vartype provider: str - :ivar resource: Resource on which the operation is performed: Invoice, etc. - :vartype resource: str - :ivar operation: Operation type: Read, write, delete, etc. - :vartype operation: str - """ - - _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, - } - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - - -class OperationListResult(msrest.serialization.Model): - """Result of the request to list ServiceBus operations. It contains a list of operations and a URL link to get the next set of results. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of ServiceBus operations supported by the Microsoft.ServiceBus resource - provider. - :vartype value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.Operation] - :ivar next_link: URL to get the next set of operation list results if there are any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class PrivateEndpoint(msrest.serialization.Model): - """PrivateEndpoint information. - - :param id: The ARM identifier for Private Endpoint. - :type id: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateEndpoint, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - - -class PrivateEndpointConnection(Resource): - """Properties of the PrivateEndpointConnection. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SystemData - :param private_endpoint: The Private Endpoint resource for this Connection. - :type private_endpoint: ~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateEndpoint - :param private_link_service_connection_state: Details about the state of the connection. - :type private_link_service_connection_state: - ~azure.mgmt.servicebus.v2021_06_01_preview.models.ConnectionState - :param provisioning_state: Provisioning state of the Private Endpoint Connection. Possible - values include: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". - :type provisioning_state: str or - ~azure.mgmt.servicebus.v2021_06_01_preview.models.EndPointProvisioningState - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'private_endpoint': {'key': 'properties.privateEndpoint', 'type': 'PrivateEndpoint'}, - 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'ConnectionState'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateEndpointConnection, self).__init__(**kwargs) - self.system_data = None - self.private_endpoint = kwargs.get('private_endpoint', None) - self.private_link_service_connection_state = kwargs.get('private_link_service_connection_state', None) - self.provisioning_state = kwargs.get('provisioning_state', None) - - -class PrivateEndpointConnectionListResult(msrest.serialization.Model): - """Result of the list of all private endpoint connections operation. - - :param value: A collection of private endpoint connection resources. - :type value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateEndpointConnection] - :param next_link: A link for the next page of private endpoint connection resources. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class PrivateLinkResource(msrest.serialization.Model): - """Information of the private link resource. - - :param id: Fully qualified identifier of the resource. - :type id: str - :param name: Name of the resource. - :type name: str - :param type: Type of the resource. - :type type: str - :param group_id: - :type group_id: str - :param required_members: Required Members. - :type required_members: list[str] - :param required_zone_names: Required Zone Names. - :type required_zone_names: list[str] - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'required_members': {'key': 'properties.requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'properties.requiredZoneNames', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateLinkResource, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.name = kwargs.get('name', None) - self.type = kwargs.get('type', None) - self.group_id = kwargs.get('group_id', None) - self.required_members = kwargs.get('required_members', None) - self.required_zone_names = kwargs.get('required_zone_names', None) - - -class PrivateLinkResourcesListResult(msrest.serialization.Model): - """Result of the List private link resources operation. - - :param value: A collection of private link resources. - :type value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateLinkResource] - :param next_link: A link for the next page of private link resources. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateLinkResourcesListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class RegenerateAccessKeyParameters(msrest.serialization.Model): - """Parameters supplied to the Regenerate Authorization Rule operation, specifies which key needs to be reset. - - All required parameters must be populated in order to send to Azure. - - :param key_type: Required. The access key to regenerate. Possible values include: "PrimaryKey", - "SecondaryKey". - :type key_type: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.KeyType - :param key: Optional, if the key value provided, is reset for KeyType value or autogenerate Key - value set for keyType. - :type key: str - """ - - _validation = { - 'key_type': {'required': True}, - } - - _attribute_map = { - 'key_type': {'key': 'keyType', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RegenerateAccessKeyParameters, self).__init__(**kwargs) - self.key_type = kwargs['key_type'] - self.key = kwargs.get('key', None) - - -class ResourceNamespacePatch(Resource): - """The Resource definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceNamespacePatch, self).__init__(**kwargs) - self.location = kwargs.get('location', None) - self.tags = kwargs.get('tags', None) - - -class Rule(Resource): - """Description of Rule Resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SystemData - :param action: Represents the filter actions which are allowed for the transformation of a - message that have been matched by a filter expression. - :type action: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Action - :param filter_type: Filter type that is evaluated against a BrokeredMessage. Possible values - include: "SqlFilter", "CorrelationFilter". - :type filter_type: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.FilterType - :param sql_filter: Properties of sqlFilter. - :type sql_filter: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SqlFilter - :param correlation_filter: Properties of correlationFilter. - :type correlation_filter: ~azure.mgmt.servicebus.v2021_06_01_preview.models.CorrelationFilter - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'action': {'key': 'properties.action', 'type': 'Action'}, - 'filter_type': {'key': 'properties.filterType', 'type': 'str'}, - 'sql_filter': {'key': 'properties.sqlFilter', 'type': 'SqlFilter'}, - 'correlation_filter': {'key': 'properties.correlationFilter', 'type': 'CorrelationFilter'}, - } - - def __init__( - self, - **kwargs - ): - super(Rule, self).__init__(**kwargs) - self.system_data = None - self.action = kwargs.get('action', None) - self.filter_type = kwargs.get('filter_type', None) - self.sql_filter = kwargs.get('sql_filter', None) - self.correlation_filter = kwargs.get('correlation_filter', None) - - -class RuleListResult(msrest.serialization.Model): - """The response of the List rule operation. - - :param value: Result of the List Rules operation. - :type value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.Rule] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list - of rules. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Rule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RuleListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class SBAuthorizationRule(Resource): - """Description of a namespace authorization rule. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SystemData - :param rights: The rights associated with the rule. - :type rights: list[str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessRights] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'rights': {'key': 'properties.rights', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(SBAuthorizationRule, self).__init__(**kwargs) - self.system_data = None - self.rights = kwargs.get('rights', None) - - -class SBAuthorizationRuleListResult(msrest.serialization.Model): - """The response to the List Namespace operation. - - :param value: Result of the List Authorization Rules operation. - :type value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list - of Authorization Rules. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SBAuthorizationRule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SBAuthorizationRuleListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class SBClientAffineProperties(msrest.serialization.Model): - """Properties specific to client affine subscriptions. - - :param client_id: Indicates the Client ID of the application that created the client-affine - subscription. - :type client_id: str - :param is_durable: For client-affine subscriptions, this value indicates whether the - subscription is durable or not. - :type is_durable: bool - :param is_shared: For client-affine subscriptions, this value indicates whether the - subscription is shared or not. - :type is_shared: bool - """ - - _attribute_map = { - 'client_id': {'key': 'clientId', 'type': 'str'}, - 'is_durable': {'key': 'isDurable', 'type': 'bool'}, - 'is_shared': {'key': 'isShared', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(SBClientAffineProperties, self).__init__(**kwargs) - self.client_id = kwargs.get('client_id', None) - self.is_durable = kwargs.get('is_durable', None) - self.is_shared = kwargs.get('is_shared', None) - - -class TrackedResource(Resource): - """The Resource definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: Required. The Geo-location where the resource lives. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(TrackedResource, self).__init__(**kwargs) - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class SBNamespace(TrackedResource): - """Description of a namespace resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: Required. The Geo-location where the resource lives. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param sku: Properties of SKU. - :type sku: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSku - :param identity: Properties of BYOK Identity description. - :type identity: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Identity - :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SystemData - :ivar provisioning_state: Provisioning state of the namespace. - :vartype provisioning_state: str - :ivar status: Status of the namespace. - :vartype status: str - :ivar created_at: The time the namespace was created. - :vartype created_at: ~datetime.datetime - :ivar updated_at: The time the namespace was updated. - :vartype updated_at: ~datetime.datetime - :ivar service_bus_endpoint: Endpoint you can use to perform Service Bus operations. - :vartype service_bus_endpoint: str - :ivar metric_id: Identifier for Azure Insights metrics. - :vartype metric_id: str - :param zone_redundant: Enabling this property creates a Premium Service Bus Namespace in - regions supported availability zones. - :type zone_redundant: bool - :param encryption: Properties of BYOK Encryption description. - :type encryption: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Encryption - :param private_endpoint_connections: List of private endpoint connections. - :type private_endpoint_connections: - list[~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateEndpointConnection] - :param disable_local_auth: This property disables SAS authentication for the Service Bus - namespace. - :type disable_local_auth: bool - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'service_bus_endpoint': {'readonly': True}, - 'metric_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'sku', 'type': 'SBSku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'service_bus_endpoint': {'key': 'properties.serviceBusEndpoint', 'type': 'str'}, - 'metric_id': {'key': 'properties.metricId', 'type': 'str'}, - 'zone_redundant': {'key': 'properties.zoneRedundant', 'type': 'bool'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'disable_local_auth': {'key': 'properties.disableLocalAuth', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(SBNamespace, self).__init__(**kwargs) - self.sku = kwargs.get('sku', None) - self.identity = kwargs.get('identity', None) - self.system_data = None - self.provisioning_state = None - self.status = None - self.created_at = None - self.updated_at = None - self.service_bus_endpoint = None - self.metric_id = None - self.zone_redundant = kwargs.get('zone_redundant', None) - self.encryption = kwargs.get('encryption', None) - self.private_endpoint_connections = kwargs.get('private_endpoint_connections', None) - self.disable_local_auth = kwargs.get('disable_local_auth', None) - - -class SBNamespaceListResult(msrest.serialization.Model): - """The response of the List Namespace operation. - - :param value: Result of the List Namespace operation. - :type value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list - of Namespaces. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SBNamespace]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SBNamespaceListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class SBNamespaceUpdateParameters(ResourceNamespacePatch): - """Description of a namespace resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param sku: Properties of SKU. - :type sku: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSku - :param identity: Properties of BYOK Identity description. - :type identity: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Identity - :ivar provisioning_state: Provisioning state of the namespace. - :vartype provisioning_state: str - :ivar status: Status of the namespace. - :vartype status: str - :ivar created_at: The time the namespace was created. - :vartype created_at: ~datetime.datetime - :ivar updated_at: The time the namespace was updated. - :vartype updated_at: ~datetime.datetime - :ivar service_bus_endpoint: Endpoint you can use to perform Service Bus operations. - :vartype service_bus_endpoint: str - :ivar metric_id: Identifier for Azure Insights metrics. - :vartype metric_id: str - :param zone_redundant: Enabling this property creates a Premium Service Bus Namespace in - regions supported availability zones. - :type zone_redundant: bool - :param encryption: Properties of BYOK Encryption description. - :type encryption: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Encryption - :param private_endpoint_connections: List of private endpoint connections. - :type private_endpoint_connections: - list[~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateEndpointConnection] - :param disable_local_auth: This property disables SAS authentication for the Service Bus - namespace. - :type disable_local_auth: bool - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'service_bus_endpoint': {'readonly': True}, - 'metric_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'sku', 'type': 'SBSku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'service_bus_endpoint': {'key': 'properties.serviceBusEndpoint', 'type': 'str'}, - 'metric_id': {'key': 'properties.metricId', 'type': 'str'}, - 'zone_redundant': {'key': 'properties.zoneRedundant', 'type': 'bool'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'disable_local_auth': {'key': 'properties.disableLocalAuth', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(SBNamespaceUpdateParameters, self).__init__(**kwargs) - self.sku = kwargs.get('sku', None) - self.identity = kwargs.get('identity', None) - self.provisioning_state = None - self.status = None - self.created_at = None - self.updated_at = None - self.service_bus_endpoint = None - self.metric_id = None - self.zone_redundant = kwargs.get('zone_redundant', None) - self.encryption = kwargs.get('encryption', None) - self.private_endpoint_connections = kwargs.get('private_endpoint_connections', None) - self.disable_local_auth = kwargs.get('disable_local_auth', None) - - -class SBQueue(Resource): - """Description of queue Resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SystemData - :ivar count_details: Message Count Details. - :vartype count_details: ~azure.mgmt.servicebus.v2021_06_01_preview.models.MessageCountDetails - :ivar created_at: The exact time the message was created. - :vartype created_at: ~datetime.datetime - :ivar updated_at: The exact time the message was 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. - :vartype accessed_at: ~datetime.datetime - :ivar size_in_bytes: The size of the queue, in bytes. - :vartype size_in_bytes: long - :ivar message_count: The number of messages in the queue. - :vartype message_count: long - :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. Default is 1024. - :type max_size_in_megabytes: int - :param max_message_size_in_kilobytes: Maximum size (in KB) of the message payload that can be - accepted by the queue. This property is only used in Premium today and default is 1024. - :type max_message_size_in_kilobytes: 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 status: Enumerates the possible values for the status of a messaging entity. Possible - values include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", - "Creating", "Deleting", "Renaming", "Unknown". - :type status: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.EntityStatus - :param enable_batched_operations: Value that indicates whether server-side batched operations - are enabled. - :type enable_batched_operations: bool - :param auto_delete_on_idle: ISO 8061 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 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_to: Queue/Topic name to forward the messages. - :type forward_to: str - :param forward_dead_lettered_messages_to: Queue/Topic name to forward the Dead Letter message. - :type forward_dead_lettered_messages_to: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'count_details': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'accessed_at': {'readonly': True}, - 'size_in_bytes': {'readonly': True}, - 'message_count': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'size_in_bytes': {'key': 'properties.sizeInBytes', 'type': 'long'}, - 'message_count': {'key': 'properties.messageCount', 'type': 'long'}, - 'lock_duration': {'key': 'properties.lockDuration', 'type': 'duration'}, - 'max_size_in_megabytes': {'key': 'properties.maxSizeInMegabytes', 'type': 'int'}, - 'max_message_size_in_kilobytes': {'key': 'properties.maxMessageSizeInKilobytes', 'type': 'long'}, - 'requires_duplicate_detection': {'key': 'properties.requiresDuplicateDetection', 'type': 'bool'}, - 'requires_session': {'key': 'properties.requiresSession', 'type': 'bool'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'duration'}, - 'dead_lettering_on_message_expiration': {'key': 'properties.deadLetteringOnMessageExpiration', 'type': 'bool'}, - 'duplicate_detection_history_time_window': {'key': 'properties.duplicateDetectionHistoryTimeWindow', 'type': 'duration'}, - 'max_delivery_count': {'key': 'properties.maxDeliveryCount', 'type': 'int'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'duration'}, - 'enable_partitioning': {'key': 'properties.enablePartitioning', 'type': 'bool'}, - 'enable_express': {'key': 'properties.enableExpress', 'type': 'bool'}, - 'forward_to': {'key': 'properties.forwardTo', 'type': 'str'}, - 'forward_dead_lettered_messages_to': {'key': 'properties.forwardDeadLetteredMessagesTo', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SBQueue, self).__init__(**kwargs) - self.system_data = None - self.count_details = None - self.created_at = None - self.updated_at = None - self.accessed_at = None - self.size_in_bytes = None - self.message_count = None - self.lock_duration = kwargs.get('lock_duration', None) - self.max_size_in_megabytes = kwargs.get('max_size_in_megabytes', None) - self.max_message_size_in_kilobytes = kwargs.get('max_message_size_in_kilobytes', 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.status = kwargs.get('status', None) - self.enable_batched_operations = kwargs.get('enable_batched_operations', None) - self.auto_delete_on_idle = kwargs.get('auto_delete_on_idle', None) - self.enable_partitioning = kwargs.get('enable_partitioning', None) - self.enable_express = kwargs.get('enable_express', None) - self.forward_to = kwargs.get('forward_to', None) - self.forward_dead_lettered_messages_to = kwargs.get('forward_dead_lettered_messages_to', None) - - -class SBQueueListResult(msrest.serialization.Model): - """The response to the List Queues operation. - - :param value: Result of the List Queues operation. - :type value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBQueue] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list - of queues. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SBQueue]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SBQueueListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class SBSku(msrest.serialization.Model): - """SKU of the namespace. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. Name of this SKU. Possible values include: "Basic", "Standard", - "Premium". - :type name: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.SkuName - :param tier: The billing tier of this particular SKU. Possible values include: "Basic", - "Standard", "Premium". - :type tier: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.SkuTier - :param capacity: The specified messaging units for the tier. For Premium tier, capacity are 1,2 - and 4. - :type capacity: int - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(SBSku, self).__init__(**kwargs) - self.name = kwargs['name'] - self.tier = kwargs.get('tier', None) - self.capacity = kwargs.get('capacity', None) - - -class SBSubscription(Resource): - """Description of subscription resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SystemData - :ivar message_count: Number of messages. - :vartype message_count: long - :ivar created_at: Exact time the message was created. - :vartype created_at: ~datetime.datetime - :ivar accessed_at: Last time there was a receive request to this subscription. - :vartype accessed_at: ~datetime.datetime - :ivar updated_at: The exact time the message was updated. - :vartype updated_at: ~datetime.datetime - :ivar count_details: Message count details. - :vartype count_details: ~azure.mgmt.servicebus.v2021_06_01_preview.models.MessageCountDetails - :param lock_duration: ISO 8061 lock duration timespan for the subscription. The default value - is 1 minute. - :type lock_duration: ~datetime.timedelta - :param requires_session: Value indicating if a subscription supports the concept of sessions. - :type requires_session: bool - :param default_message_time_to_live: ISO 8061 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_filter_evaluation_exceptions: Value that indicates whether a - subscription has dead letter support on filter evaluation exceptions. - :type dead_lettering_on_filter_evaluation_exceptions: bool - :param dead_lettering_on_message_expiration: Value that indicates whether a subscription 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: Number of maximum deliveries. - :type max_delivery_count: int - :param status: Enumerates the possible values for the status of a messaging entity. Possible - values include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", - "Creating", "Deleting", "Renaming", "Unknown". - :type status: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.EntityStatus - :param enable_batched_operations: Value that indicates whether server-side batched operations - are enabled. - :type enable_batched_operations: bool - :param auto_delete_on_idle: ISO 8061 timeSpan idle interval after which the topic is - automatically deleted. The minimum duration is 5 minutes. - :type auto_delete_on_idle: ~datetime.timedelta - :param forward_to: Queue/Topic name to forward the messages. - :type forward_to: str - :param forward_dead_lettered_messages_to: Queue/Topic name to forward the Dead Letter message. - :type forward_dead_lettered_messages_to: str - :param is_client_affine: Value that indicates whether the subscription has an affinity to the - client id. - :type is_client_affine: bool - :param client_affine_properties: Properties specific to client affine subscriptions. - :type client_affine_properties: - ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBClientAffineProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'message_count': {'readonly': True}, - 'created_at': {'readonly': True}, - 'accessed_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'count_details': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'message_count': {'key': 'properties.messageCount', 'type': 'long'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'lock_duration': {'key': 'properties.lockDuration', 'type': 'duration'}, - 'requires_session': {'key': 'properties.requiresSession', 'type': 'bool'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'duration'}, - 'dead_lettering_on_filter_evaluation_exceptions': {'key': 'properties.deadLetteringOnFilterEvaluationExceptions', 'type': 'bool'}, - 'dead_lettering_on_message_expiration': {'key': 'properties.deadLetteringOnMessageExpiration', 'type': 'bool'}, - 'duplicate_detection_history_time_window': {'key': 'properties.duplicateDetectionHistoryTimeWindow', 'type': 'duration'}, - 'max_delivery_count': {'key': 'properties.maxDeliveryCount', 'type': 'int'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'duration'}, - 'forward_to': {'key': 'properties.forwardTo', 'type': 'str'}, - 'forward_dead_lettered_messages_to': {'key': 'properties.forwardDeadLetteredMessagesTo', 'type': 'str'}, - 'is_client_affine': {'key': 'properties.isClientAffine', 'type': 'bool'}, - 'client_affine_properties': {'key': 'properties.clientAffineProperties', 'type': 'SBClientAffineProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(SBSubscription, self).__init__(**kwargs) - self.system_data = None - self.message_count = None - self.created_at = None - self.accessed_at = None - self.updated_at = None - self.count_details = None - self.lock_duration = kwargs.get('lock_duration', None) - self.requires_session = kwargs.get('requires_session', None) - self.default_message_time_to_live = kwargs.get('default_message_time_to_live', None) - self.dead_lettering_on_filter_evaluation_exceptions = kwargs.get('dead_lettering_on_filter_evaluation_exceptions', 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.status = kwargs.get('status', None) - self.enable_batched_operations = kwargs.get('enable_batched_operations', None) - self.auto_delete_on_idle = kwargs.get('auto_delete_on_idle', None) - self.forward_to = kwargs.get('forward_to', None) - self.forward_dead_lettered_messages_to = kwargs.get('forward_dead_lettered_messages_to', None) - self.is_client_affine = kwargs.get('is_client_affine', None) - self.client_affine_properties = kwargs.get('client_affine_properties', None) - - -class SBSubscriptionListResult(msrest.serialization.Model): - """The response to the List Subscriptions operation. - - :param value: Result of the List Subscriptions operation. - :type value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSubscription] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list - of subscriptions. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SBSubscription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SBSubscriptionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class SBTopic(Resource): - """Description of topic resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SystemData - :ivar size_in_bytes: Size of the topic, in bytes. - :vartype size_in_bytes: long - :ivar created_at: Exact time the message was created. - :vartype created_at: ~datetime.datetime - :ivar updated_at: The exact time the message was updated. - :vartype updated_at: ~datetime.datetime - :ivar accessed_at: Last time the message was sent, or a request was received, for this topic. - :vartype accessed_at: ~datetime.datetime - :ivar subscription_count: Number of subscriptions. - :vartype subscription_count: int - :ivar count_details: Message count details. - :vartype count_details: ~azure.mgmt.servicebus.v2021_06_01_preview.models.MessageCountDetails - :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: Maximum size of the topic in megabytes, which is the size of the - memory allocated for the topic. Default is 1024. - :type max_size_in_megabytes: int - :param max_message_size_in_kilobytes: Maximum size (in KB) of the message payload that can be - accepted by the topic. This property is only used in Premium today and default is 1024. - :type max_message_size_in_kilobytes: long - :param requires_duplicate_detection: Value indicating if this topic requires duplicate - detection. - :type requires_duplicate_detection: bool - :param duplicate_detection_history_time_window: ISO8601 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 status: Enumerates the possible values for the status of a messaging entity. Possible - values include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", - "Creating", "Deleting", "Renaming", "Unknown". - :type status: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.EntityStatus - :param support_ordering: Value that indicates whether the topic supports ordering. - :type support_ordering: bool - :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: Value that indicates whether the topic to be partitioned across - multiple message brokers is enabled. - :type enable_partitioning: bool - :param enable_express: 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 - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'size_in_bytes': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'accessed_at': {'readonly': True}, - 'subscription_count': {'readonly': True}, - 'count_details': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'size_in_bytes': {'key': 'properties.sizeInBytes', 'type': 'long'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'accessed_at': {'key': 'properties.accessedAt', 'type': 'iso-8601'}, - 'subscription_count': {'key': 'properties.subscriptionCount', 'type': 'int'}, - 'count_details': {'key': 'properties.countDetails', 'type': 'MessageCountDetails'}, - 'default_message_time_to_live': {'key': 'properties.defaultMessageTimeToLive', 'type': 'duration'}, - 'max_size_in_megabytes': {'key': 'properties.maxSizeInMegabytes', 'type': 'int'}, - 'max_message_size_in_kilobytes': {'key': 'properties.maxMessageSizeInKilobytes', 'type': 'long'}, - 'requires_duplicate_detection': {'key': 'properties.requiresDuplicateDetection', 'type': 'bool'}, - 'duplicate_detection_history_time_window': {'key': 'properties.duplicateDetectionHistoryTimeWindow', 'type': 'duration'}, - 'enable_batched_operations': {'key': 'properties.enableBatchedOperations', 'type': 'bool'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'support_ordering': {'key': 'properties.supportOrdering', 'type': 'bool'}, - 'auto_delete_on_idle': {'key': 'properties.autoDeleteOnIdle', 'type': 'duration'}, - 'enable_partitioning': {'key': 'properties.enablePartitioning', 'type': 'bool'}, - 'enable_express': {'key': 'properties.enableExpress', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(SBTopic, self).__init__(**kwargs) - self.system_data = None - self.size_in_bytes = None - self.created_at = None - self.updated_at = None - self.accessed_at = None - self.subscription_count = None - self.count_details = None - self.default_message_time_to_live = kwargs.get('default_message_time_to_live', None) - self.max_size_in_megabytes = kwargs.get('max_size_in_megabytes', None) - self.max_message_size_in_kilobytes = kwargs.get('max_message_size_in_kilobytes', 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.status = kwargs.get('status', None) - self.support_ordering = kwargs.get('support_ordering', None) - self.auto_delete_on_idle = kwargs.get('auto_delete_on_idle', None) - self.enable_partitioning = kwargs.get('enable_partitioning', None) - self.enable_express = kwargs.get('enable_express', None) - - -class SBTopicListResult(msrest.serialization.Model): - """The response to the List Topics operation. - - :param value: Result of the List Topics operation. - :type value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBTopic] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list - of topics. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SBTopic]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SBTopicListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class SqlFilter(msrest.serialization.Model): - """Represents a filter which is a composition of an expression and an action that is executed in the pub/sub pipeline. - - :param sql_expression: The SQL expression. e.g. MyProperty='ABC'. - :type sql_expression: str - :param compatibility_level: This property is reserved for future use. An integer value showing - the compatibility level, currently hard-coded to 20. - :type compatibility_level: int - :param requires_preprocessing: Value that indicates whether the rule action requires - preprocessing. - :type requires_preprocessing: bool - """ - - _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(SqlFilter, self).__init__(**kwargs) - self.sql_expression = kwargs.get('sql_expression', None) - self.compatibility_level = kwargs.get('compatibility_level', None) - self.requires_preprocessing = kwargs.get('requires_preprocessing', True) - - -class SqlRuleAction(Action): - """Represents set of actions written in SQL language-based syntax that is performed against a ServiceBus.Messaging.BrokeredMessage. - - :param sql_expression: SQL expression. e.g. MyProperty='ABC'. - :type sql_expression: str - :param compatibility_level: This property is reserved for future use. An integer value showing - the compatibility level, currently hard-coded to 20. - :type compatibility_level: int - :param requires_preprocessing: Value that indicates whether the rule action requires - preprocessing. - :type requires_preprocessing: bool - """ - - _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(SqlRuleAction, self).__init__(**kwargs) - - -class Subnet(msrest.serialization.Model): - """Properties supplied for Subnet. - - All required parameters must be populated in order to send to Azure. - - :param id: Required. Resource ID of Virtual Network Subnet. - :type id: str - """ - - _validation = { - 'id': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Subnet, self).__init__(**kwargs) - self.id = kwargs['id'] - - -class SystemData(msrest.serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or - ~azure.mgmt.servicebus.v2021_06_01_preview.models.CreatedByType - :param last_modified_at: The type of identity that last modified the resource. - :type last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(SystemData, self).__init__(**kwargs) - self.created_by = kwargs.get('created_by', None) - self.created_by_type = kwargs.get('created_by_type', None) - self.created_at = kwargs.get('created_at', None) - self.last_modified_by = kwargs.get('last_modified_by', None) - self.last_modified_by_type = kwargs.get('last_modified_by_type', None) - self.last_modified_at = kwargs.get('last_modified_at', None) - - -class UserAssignedIdentity(msrest.serialization.Model): - """Recognized Dictionary value. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: Principal Id of user assigned identity. - :vartype principal_id: str - :ivar client_id: Client Id of user assigned identity. - :vartype client_id: str - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserAssignedIdentity, self).__init__(**kwargs) - self.principal_id = None - self.client_id = None - - -class UserAssignedIdentityProperties(msrest.serialization.Model): - """UserAssignedIdentityProperties. - - :param user_assigned_identity: ARM ID of user Identity selected for encryption. - :type user_assigned_identity: str - """ - - _attribute_map = { - 'user_assigned_identity': {'key': 'userAssignedIdentity', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserAssignedIdentityProperties, self).__init__(**kwargs) - self.user_assigned_identity = kwargs.get('user_assigned_identity', None) diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/models/_models_py3.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/models/_models_py3.py index 1fa034244d7d..7f62cd506bcf 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/models/_models_py3.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/models/_models_py3.py @@ -66,6 +66,8 @@ def __init__( self, **kwargs ): + """ + """ super(AccessKeys, self).__init__(**kwargs) self.primary_connection_string = None self.secondary_connection_string = None @@ -79,14 +81,14 @@ def __init__( class Action(msrest.serialization.Model): """Represents the filter actions which are allowed for the transformation of a message that have been matched by a filter expression. - :param sql_expression: SQL expression. e.g. MyProperty='ABC'. - :type sql_expression: str - :param compatibility_level: This property is reserved for future use. An integer value showing + :ivar sql_expression: SQL expression. e.g. MyProperty='ABC'. + :vartype sql_expression: str + :ivar compatibility_level: This property is reserved for future use. An integer value showing the compatibility level, currently hard-coded to 20. - :type compatibility_level: int - :param requires_preprocessing: Value that indicates whether the rule action requires + :vartype compatibility_level: int + :ivar requires_preprocessing: Value that indicates whether the rule action requires preprocessing. - :type requires_preprocessing: bool + :vartype requires_preprocessing: bool """ _attribute_map = { @@ -103,6 +105,16 @@ def __init__( requires_preprocessing: Optional[bool] = True, **kwargs ): + """ + :keyword sql_expression: SQL expression. e.g. MyProperty='ABC'. + :paramtype sql_expression: str + :keyword compatibility_level: This property is reserved for future use. An integer value + showing the compatibility level, currently hard-coded to 20. + :paramtype compatibility_level: int + :keyword requires_preprocessing: Value that indicates whether the rule action requires + preprocessing. + :paramtype requires_preprocessing: bool + """ super(Action, self).__init__(**kwargs) self.sql_expression = sql_expression self.compatibility_level = compatibility_level @@ -138,6 +150,8 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -164,12 +178,12 @@ class ArmDisasterRecovery(Resource): ~azure.mgmt.servicebus.v2021_06_01_preview.models.ProvisioningStateDR :ivar pending_replication_operations_count: Number of entities pending to be replicated. :vartype pending_replication_operations_count: long - :param partner_namespace: ARM Id of the Primary/Secondary eventhub namespace name, which is - part of GEO DR pairing. - :type partner_namespace: str - :param alternate_name: Primary/Secondary eventhub namespace name, which is part of GEO DR + :ivar partner_namespace: ARM Id of the Primary/Secondary eventhub namespace name, which is part + of GEO DR pairing. + :vartype partner_namespace: str + :ivar alternate_name: Primary/Secondary eventhub namespace name, which is part of GEO DR pairing. - :type alternate_name: str + :vartype alternate_name: str :ivar role: role of namespace in GEO DR - possible values 'Primary' or 'PrimaryNotReplicating' or 'Secondary'. Possible values include: "Primary", "PrimaryNotReplicating", "Secondary". :vartype role: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.RoleDisasterRecovery @@ -204,6 +218,14 @@ def __init__( alternate_name: Optional[str] = None, **kwargs ): + """ + :keyword partner_namespace: ARM Id of the Primary/Secondary eventhub namespace name, which is + part of GEO DR pairing. + :paramtype partner_namespace: str + :keyword alternate_name: Primary/Secondary eventhub namespace name, which is part of GEO DR + pairing. + :paramtype alternate_name: str + """ super(ArmDisasterRecovery, self).__init__(**kwargs) self.system_data = None self.provisioning_state = None @@ -218,8 +240,8 @@ class ArmDisasterRecoveryListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: List of Alias(Disaster Recovery configurations). - :type value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.ArmDisasterRecovery] + :ivar value: List of Alias(Disaster Recovery configurations). + :vartype value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.ArmDisasterRecovery] :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of Alias(Disaster Recovery configuration). :vartype next_link: str @@ -240,6 +262,10 @@ def __init__( value: Optional[List["ArmDisasterRecovery"]] = None, **kwargs ): + """ + :keyword value: List of Alias(Disaster Recovery configurations). + :paramtype value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.ArmDisasterRecovery] + """ super(ArmDisasterRecoveryListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -250,10 +276,10 @@ class CheckNameAvailability(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The Name to check the namespace name availability and The namespace name + :ivar name: Required. The Name to check the namespace name availability and The namespace name can contain only letters, numbers, and hyphens. The namespace must start with a letter, and it must end with a letter or number. - :type name: str + :vartype name: str """ _validation = { @@ -270,6 +296,12 @@ def __init__( name: str, **kwargs ): + """ + :keyword name: Required. The Name to check the namespace name availability and The namespace + name can contain only letters, numbers, and hyphens. The namespace must start with a letter, + and it must end with a letter or number. + :paramtype name: str + """ super(CheckNameAvailability, self).__init__(**kwargs) self.name = name @@ -281,13 +313,13 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): :ivar message: The detailed info regarding the reason associated with the namespace. :vartype message: str - :param name_available: Value indicating namespace is availability, true if the namespace is + :ivar name_available: Value indicating namespace is availability, true if the namespace is available; otherwise, false. - :type name_available: bool - :param reason: The reason for unavailability of a namespace. Possible values include: "None", + :vartype name_available: bool + :ivar reason: The reason for unavailability of a namespace. Possible values include: "None", "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", "TooManyNamespaceInCurrentSubscription". - :type reason: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.UnavailableReason + :vartype reason: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.UnavailableReason """ _validation = { @@ -307,6 +339,15 @@ def __init__( reason: Optional[Union[str, "UnavailableReason"]] = None, **kwargs ): + """ + :keyword name_available: Value indicating namespace is availability, true if the namespace is + available; otherwise, false. + :paramtype name_available: bool + :keyword reason: The reason for unavailability of a namespace. Possible values include: "None", + "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", + "TooManyNamespaceInCurrentSubscription". + :paramtype reason: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.UnavailableReason + """ super(CheckNameAvailabilityResult, self).__init__(**kwargs) self.message = None self.name_available = name_available @@ -316,12 +357,12 @@ def __init__( class ConnectionState(msrest.serialization.Model): """ConnectionState information. - :param status: Status of the connection. Possible values include: "Pending", "Approved", + :ivar status: Status of the connection. Possible values include: "Pending", "Approved", "Rejected", "Disconnected". - :type status: str or + :vartype status: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateLinkConnectionStatus - :param description: Description of the connection state. - :type description: str + :ivar description: Description of the connection state. + :vartype description: str """ _attribute_map = { @@ -336,6 +377,14 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword status: Status of the connection. Possible values include: "Pending", "Approved", + "Rejected", "Disconnected". + :paramtype status: str or + ~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateLinkConnectionStatus + :keyword description: Description of the connection state. + :paramtype description: str + """ super(ConnectionState, self).__init__(**kwargs) self.status = status self.description = description @@ -344,27 +393,27 @@ def __init__( class CorrelationFilter(msrest.serialization.Model): """Represents the correlation filter expression. - :param properties: dictionary object for custom filters. - :type properties: dict[str, str] - :param correlation_id: Identifier of the correlation. - :type correlation_id: str - :param message_id: Identifier of the message. - :type message_id: str - :param to: Address to send to. - :type to: str - :param reply_to: Address of the queue to reply to. - :type reply_to: str - :param label: Application specific label. - :type label: str - :param session_id: Session identifier. - :type session_id: str - :param reply_to_session_id: Session identifier to reply to. - :type reply_to_session_id: str - :param content_type: Content type of the message. - :type content_type: str - :param requires_preprocessing: Value that indicates whether the rule action requires + :ivar properties: dictionary object for custom filters. + :vartype properties: dict[str, str] + :ivar correlation_id: Identifier of the correlation. + :vartype correlation_id: str + :ivar message_id: Identifier of the message. + :vartype message_id: str + :ivar to: Address to send to. + :vartype to: str + :ivar reply_to: Address of the queue to reply to. + :vartype reply_to: str + :ivar label: Application specific label. + :vartype label: str + :ivar session_id: Session identifier. + :vartype session_id: str + :ivar reply_to_session_id: Session identifier to reply to. + :vartype reply_to_session_id: str + :ivar content_type: Content type of the message. + :vartype content_type: str + :ivar requires_preprocessing: Value that indicates whether the rule action requires preprocessing. - :type requires_preprocessing: bool + :vartype requires_preprocessing: bool """ _attribute_map = { @@ -395,6 +444,29 @@ def __init__( requires_preprocessing: Optional[bool] = True, **kwargs ): + """ + :keyword properties: dictionary object for custom filters. + :paramtype properties: dict[str, str] + :keyword correlation_id: Identifier of the correlation. + :paramtype correlation_id: str + :keyword message_id: Identifier of the message. + :paramtype message_id: str + :keyword to: Address to send to. + :paramtype to: str + :keyword reply_to: Address of the queue to reply to. + :paramtype reply_to: str + :keyword label: Application specific label. + :paramtype label: str + :keyword session_id: Session identifier. + :paramtype session_id: str + :keyword reply_to_session_id: Session identifier to reply to. + :paramtype reply_to_session_id: str + :keyword content_type: Content type of the message. + :paramtype content_type: str + :keyword requires_preprocessing: Value that indicates whether the rule action requires + preprocessing. + :paramtype requires_preprocessing: bool + """ super(CorrelationFilter, self).__init__(**kwargs) self.properties = properties self.correlation_id = correlation_id @@ -411,15 +483,15 @@ def __init__( class Encryption(msrest.serialization.Model): """Properties to configure Encryption. - :param key_vault_properties: Properties of KeyVault. - :type key_vault_properties: + :ivar key_vault_properties: Properties of KeyVault. + :vartype key_vault_properties: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.KeyVaultProperties] - :param key_source: Enumerates the possible value of keySource for Encryption. The only + :ivar key_source: Enumerates the possible value of keySource for Encryption. The only acceptable values to pass in are None and "Microsoft.KeyVault". The default value is "Microsoft.KeyVault". - :type key_source: str - :param require_infrastructure_encryption: Enable Infrastructure Encryption (Double Encryption). - :type require_infrastructure_encryption: bool + :vartype key_source: str + :ivar require_infrastructure_encryption: Enable Infrastructure Encryption (Double Encryption). + :vartype require_infrastructure_encryption: bool """ _attribute_map = { @@ -436,6 +508,18 @@ def __init__( require_infrastructure_encryption: Optional[bool] = None, **kwargs ): + """ + :keyword key_vault_properties: Properties of KeyVault. + :paramtype key_vault_properties: + list[~azure.mgmt.servicebus.v2021_06_01_preview.models.KeyVaultProperties] + :keyword key_source: Enumerates the possible value of keySource for Encryption. The only + acceptable values to pass in are None and "Microsoft.KeyVault". The default value is + "Microsoft.KeyVault". + :paramtype key_source: str + :keyword require_infrastructure_encryption: Enable Infrastructure Encryption (Double + Encryption). + :paramtype require_infrastructure_encryption: bool + """ super(Encryption, self).__init__(**kwargs) self.key_vault_properties = key_vault_properties self.key_source = key_source @@ -467,6 +551,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -475,8 +561,8 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """The resource management error response. - :param error: The error object. - :type error: ~azure.mgmt.servicebus.v2021_06_01_preview.models.ErrorResponseError + :ivar error: The error object. + :vartype error: ~azure.mgmt.servicebus.v2021_06_01_preview.models.ErrorResponseError """ _attribute_map = { @@ -489,6 +575,10 @@ def __init__( error: Optional["ErrorResponseError"] = None, **kwargs ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.servicebus.v2021_06_01_preview.models.ErrorResponseError + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -531,6 +621,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponseError, self).__init__(**kwargs) self.code = None self.message = None @@ -542,9 +634,9 @@ def __init__( class FailoverProperties(msrest.serialization.Model): """Safe failover is to indicate the service should wait for pending replication to finish before switching to the secondary. - :param is_safe_failover: Safe failover is to indicate the service should wait for pending + :ivar is_safe_failover: Safe failover is to indicate the service should wait for pending replication to finish before switching to the secondary. - :type is_safe_failover: bool + :vartype is_safe_failover: bool """ _attribute_map = { @@ -557,6 +649,11 @@ def __init__( is_safe_failover: Optional[bool] = None, **kwargs ): + """ + :keyword is_safe_failover: Safe failover is to indicate the service should wait for pending + replication to finish before switching to the secondary. + :paramtype is_safe_failover: bool + """ super(FailoverProperties, self).__init__(**kwargs) self.is_safe_failover = is_safe_failover @@ -570,11 +667,12 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: TenantId from the KeyVault. :vartype tenant_id: str - :param type: Type of managed service identity. Possible values include: "SystemAssigned", + :ivar type: Type of managed service identity. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". - :type type: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.ManagedServiceIdentityType - :param user_assigned_identities: Properties for User Assigned Identities. - :type user_assigned_identities: dict[str, + :vartype type: str or + ~azure.mgmt.servicebus.v2021_06_01_preview.models.ManagedServiceIdentityType + :ivar user_assigned_identities: Properties for User Assigned Identities. + :vartype user_assigned_identities: dict[str, ~azure.mgmt.servicebus.v2021_06_01_preview.models.UserAssignedIdentity] """ @@ -597,6 +695,15 @@ def __init__( user_assigned_identities: Optional[Dict[str, "UserAssignedIdentity"]] = None, **kwargs ): + """ + :keyword type: Type of managed service identity. Possible values include: "SystemAssigned", + "UserAssigned", "SystemAssigned, UserAssigned", "None". + :paramtype type: str or + ~azure.mgmt.servicebus.v2021_06_01_preview.models.ManagedServiceIdentityType + :keyword user_assigned_identities: Properties for User Assigned Identities. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.servicebus.v2021_06_01_preview.models.UserAssignedIdentity] + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -607,14 +714,14 @@ def __init__( class KeyVaultProperties(msrest.serialization.Model): """Properties to configure keyVault Properties. - :param key_name: Name of the Key from KeyVault. - :type key_name: str - :param key_vault_uri: Uri of KeyVault. - :type key_vault_uri: str - :param key_version: Version of KeyVault. - :type key_version: str - :param identity: - :type identity: + :ivar key_name: Name of the Key from KeyVault. + :vartype key_name: str + :ivar key_vault_uri: Uri of KeyVault. + :vartype key_vault_uri: str + :ivar key_version: Version of KeyVault. + :vartype key_version: str + :ivar identity: + :vartype identity: ~azure.mgmt.servicebus.v2021_06_01_preview.models.UserAssignedIdentityProperties """ @@ -634,6 +741,17 @@ def __init__( identity: Optional["UserAssignedIdentityProperties"] = None, **kwargs ): + """ + :keyword key_name: Name of the Key from KeyVault. + :paramtype key_name: str + :keyword key_vault_uri: Uri of KeyVault. + :paramtype key_vault_uri: str + :keyword key_version: Version of KeyVault. + :paramtype key_version: str + :keyword identity: + :paramtype identity: + ~azure.mgmt.servicebus.v2021_06_01_preview.models.UserAssignedIdentityProperties + """ super(KeyVaultProperties, self).__init__(**kwargs) self.key_name = key_name self.key_vault_uri = key_vault_uri @@ -679,6 +797,8 @@ def __init__( self, **kwargs ): + """ + """ super(MessageCountDetails, self).__init__(**kwargs) self.active_message_count = None self.dead_letter_message_count = None @@ -692,8 +812,9 @@ class MigrationConfigListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: List of Migration Configs. - :type value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigProperties] + :ivar value: List of Migration Configs. + :vartype value: + list[~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigProperties] :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of migrationConfigurations. :vartype next_link: str @@ -714,6 +835,11 @@ def __init__( value: Optional[List["MigrationConfigProperties"]] = None, **kwargs ): + """ + :keyword value: List of Migration Configs. + :paramtype value: + list[~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigProperties] + """ super(MigrationConfigListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -736,11 +862,11 @@ class MigrationConfigProperties(Resource): :vartype provisioning_state: str :ivar pending_replication_operations_count: Number of entities pending to be replicated. :vartype pending_replication_operations_count: long - :param target_namespace: Existing premium Namespace ARM Id name which has no entities, will be + :ivar target_namespace: Existing premium Namespace ARM Id name which has no entities, will be used for migration. - :type target_namespace: str - :param post_migration_name: Name to access Standard Namespace after migration. - :type post_migration_name: str + :vartype target_namespace: str + :ivar post_migration_name: Name to access Standard Namespace after migration. + :vartype post_migration_name: str :ivar migration_state: State in which Standard to Premium Migration is, possible values : Unknown, Reverting, Completing, Initiating, Syncing, Active. :vartype migration_state: str @@ -775,6 +901,13 @@ def __init__( post_migration_name: Optional[str] = None, **kwargs ): + """ + :keyword target_namespace: Existing premium Namespace ARM Id name which has no entities, will + be used for migration. + :paramtype target_namespace: str + :keyword post_migration_name: Name to access Standard Namespace after migration. + :paramtype post_migration_name: str + """ super(MigrationConfigProperties, self).__init__(**kwargs) self.system_data = None self.provisioning_state = None @@ -797,21 +930,21 @@ class NetworkRuleSet(Resource): :vartype type: str :ivar system_data: The system meta data relating to this resource. :vartype system_data: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SystemData - :param trusted_service_access_enabled: Value that indicates whether Trusted Service Access is + :ivar trusted_service_access_enabled: Value that indicates whether Trusted Service Access is Enabled or not. - :type trusted_service_access_enabled: bool - :param default_action: Default Action for Network Rule Set. Possible values include: "Allow", + :vartype trusted_service_access_enabled: bool + :ivar default_action: Default Action for Network Rule Set. Possible values include: "Allow", "Deny". - :type default_action: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.DefaultAction - :param virtual_network_rules: List VirtualNetwork Rules. - :type virtual_network_rules: + :vartype default_action: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.DefaultAction + :ivar virtual_network_rules: List VirtualNetwork Rules. + :vartype virtual_network_rules: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.NWRuleSetVirtualNetworkRules] - :param ip_rules: List of IpRules. - :type ip_rules: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.NWRuleSetIpRules] - :param public_network_access: This determines if traffic is allowed over public network. By + :ivar ip_rules: List of IpRules. + :vartype ip_rules: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.NWRuleSetIpRules] + :ivar public_network_access: This determines if traffic is allowed over public network. By default it is enabled. Possible values include: "Enabled", "Disabled". Default value: "Enabled". - :type public_network_access: str or + :vartype public_network_access: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.PublicNetworkAccessFlag """ @@ -844,6 +977,25 @@ def __init__( public_network_access: Optional[Union[str, "PublicNetworkAccessFlag"]] = "Enabled", **kwargs ): + """ + :keyword trusted_service_access_enabled: Value that indicates whether Trusted Service Access is + Enabled or not. + :paramtype trusted_service_access_enabled: bool + :keyword default_action: Default Action for Network Rule Set. Possible values include: "Allow", + "Deny". + :paramtype default_action: str or + ~azure.mgmt.servicebus.v2021_06_01_preview.models.DefaultAction + :keyword virtual_network_rules: List VirtualNetwork Rules. + :paramtype virtual_network_rules: + list[~azure.mgmt.servicebus.v2021_06_01_preview.models.NWRuleSetVirtualNetworkRules] + :keyword ip_rules: List of IpRules. + :paramtype ip_rules: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.NWRuleSetIpRules] + :keyword public_network_access: This determines if traffic is allowed over public network. By + default it is enabled. Possible values include: "Enabled", "Disabled". Default value: + "Enabled". + :paramtype public_network_access: str or + ~azure.mgmt.servicebus.v2021_06_01_preview.models.PublicNetworkAccessFlag + """ super(NetworkRuleSet, self).__init__(**kwargs) self.system_data = None self.trusted_service_access_enabled = trusted_service_access_enabled @@ -856,11 +1008,11 @@ def __init__( class NetworkRuleSetListResult(msrest.serialization.Model): """The response of the List NetworkRuleSet operation. - :param value: Result of the List NetworkRuleSet operation. - :type value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleSet] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list + :ivar value: Result of the List NetworkRuleSet operation. + :vartype value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleSet] + :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of NetworkRuleSet. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -875,6 +1027,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of the List NetworkRuleSet operation. + :paramtype value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleSet] + :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete + list of NetworkRuleSet. + :paramtype next_link: str + """ super(NetworkRuleSetListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -883,10 +1042,10 @@ def __init__( class NWRuleSetIpRules(msrest.serialization.Model): """Description of NetWorkRuleSet - IpRules resource. - :param ip_mask: IP Mask. - :type ip_mask: str - :param action: The IP Filter Action. Possible values include: "Allow". Default value: "Allow". - :type action: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleIPAction + :ivar ip_mask: IP Mask. + :vartype ip_mask: str + :ivar action: The IP Filter Action. Possible values include: "Allow". Default value: "Allow". + :vartype action: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleIPAction """ _attribute_map = { @@ -901,6 +1060,13 @@ def __init__( action: Optional[Union[str, "NetworkRuleIPAction"]] = "Allow", **kwargs ): + """ + :keyword ip_mask: IP Mask. + :paramtype ip_mask: str + :keyword action: The IP Filter Action. Possible values include: "Allow". Default value: + "Allow". + :paramtype action: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleIPAction + """ super(NWRuleSetIpRules, self).__init__(**kwargs) self.ip_mask = ip_mask self.action = action @@ -909,11 +1075,11 @@ def __init__( class NWRuleSetVirtualNetworkRules(msrest.serialization.Model): """Description of VirtualNetworkRules - NetworkRules resource. - :param subnet: Subnet properties. - :type subnet: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Subnet - :param ignore_missing_vnet_service_endpoint: Value that indicates whether to ignore missing - VNet Service Endpoint. - :type ignore_missing_vnet_service_endpoint: bool + :ivar subnet: Subnet properties. + :vartype subnet: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Subnet + :ivar ignore_missing_vnet_service_endpoint: Value that indicates whether to ignore missing VNet + Service Endpoint. + :vartype ignore_missing_vnet_service_endpoint: bool """ _attribute_map = { @@ -928,6 +1094,13 @@ def __init__( ignore_missing_vnet_service_endpoint: Optional[bool] = None, **kwargs ): + """ + :keyword subnet: Subnet properties. + :paramtype subnet: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Subnet + :keyword ignore_missing_vnet_service_endpoint: Value that indicates whether to ignore missing + VNet Service Endpoint. + :paramtype ignore_missing_vnet_service_endpoint: bool + """ super(NWRuleSetVirtualNetworkRules, self).__init__(**kwargs) self.subnet = subnet self.ignore_missing_vnet_service_endpoint = ignore_missing_vnet_service_endpoint @@ -940,8 +1113,8 @@ class Operation(msrest.serialization.Model): :ivar name: Operation name: {provider}/{resource}/{operation}. :vartype name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.servicebus.v2021_06_01_preview.models.OperationDisplay + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.servicebus.v2021_06_01_preview.models.OperationDisplay """ _validation = { @@ -959,6 +1132,10 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.servicebus.v2021_06_01_preview.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = None self.display = display @@ -993,6 +1170,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = None self.resource = None @@ -1025,6 +1204,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -1033,8 +1214,8 @@ def __init__( class PrivateEndpoint(msrest.serialization.Model): """PrivateEndpoint information. - :param id: The ARM identifier for Private Endpoint. - :type id: str + :ivar id: The ARM identifier for Private Endpoint. + :vartype id: str """ _attribute_map = { @@ -1047,6 +1228,10 @@ def __init__( id: Optional[str] = None, **kwargs ): + """ + :keyword id: The ARM identifier for Private Endpoint. + :paramtype id: str + """ super(PrivateEndpoint, self).__init__(**kwargs) self.id = id @@ -1064,14 +1249,14 @@ class PrivateEndpointConnection(Resource): :vartype type: str :ivar system_data: The system meta data relating to this resource. :vartype system_data: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SystemData - :param private_endpoint: The Private Endpoint resource for this Connection. - :type private_endpoint: ~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateEndpoint - :param private_link_service_connection_state: Details about the state of the connection. - :type private_link_service_connection_state: + :ivar private_endpoint: The Private Endpoint resource for this Connection. + :vartype private_endpoint: ~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateEndpoint + :ivar private_link_service_connection_state: Details about the state of the connection. + :vartype private_link_service_connection_state: ~azure.mgmt.servicebus.v2021_06_01_preview.models.ConnectionState - :param provisioning_state: Provisioning state of the Private Endpoint Connection. Possible + :ivar provisioning_state: Provisioning state of the Private Endpoint Connection. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". - :type provisioning_state: str or + :vartype provisioning_state: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.EndPointProvisioningState """ @@ -1100,6 +1285,17 @@ def __init__( provisioning_state: Optional[Union[str, "EndPointProvisioningState"]] = None, **kwargs ): + """ + :keyword private_endpoint: The Private Endpoint resource for this Connection. + :paramtype private_endpoint: ~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateEndpoint + :keyword private_link_service_connection_state: Details about the state of the connection. + :paramtype private_link_service_connection_state: + ~azure.mgmt.servicebus.v2021_06_01_preview.models.ConnectionState + :keyword provisioning_state: Provisioning state of the Private Endpoint Connection. Possible + values include: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". + :paramtype provisioning_state: str or + ~azure.mgmt.servicebus.v2021_06_01_preview.models.EndPointProvisioningState + """ super(PrivateEndpointConnection, self).__init__(**kwargs) self.system_data = None self.private_endpoint = private_endpoint @@ -1110,10 +1306,11 @@ def __init__( class PrivateEndpointConnectionListResult(msrest.serialization.Model): """Result of the list of all private endpoint connections operation. - :param value: A collection of private endpoint connection resources. - :type value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateEndpointConnection] - :param next_link: A link for the next page of private endpoint connection resources. - :type next_link: str + :ivar value: A collection of private endpoint connection resources. + :vartype value: + list[~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateEndpointConnection] + :ivar next_link: A link for the next page of private endpoint connection resources. + :vartype next_link: str """ _attribute_map = { @@ -1128,6 +1325,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: A collection of private endpoint connection resources. + :paramtype value: + list[~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateEndpointConnection] + :keyword next_link: A link for the next page of private endpoint connection resources. + :paramtype next_link: str + """ super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1136,18 +1340,18 @@ def __init__( class PrivateLinkResource(msrest.serialization.Model): """Information of the private link resource. - :param id: Fully qualified identifier of the resource. - :type id: str - :param name: Name of the resource. - :type name: str - :param type: Type of the resource. - :type type: str - :param group_id: - :type group_id: str - :param required_members: Required Members. - :type required_members: list[str] - :param required_zone_names: Required Zone Names. - :type required_zone_names: list[str] + :ivar id: Fully qualified identifier of the resource. + :vartype id: str + :ivar name: Name of the resource. + :vartype name: str + :ivar type: Type of the resource. + :vartype type: str + :ivar group_id: + :vartype group_id: str + :ivar required_members: Required Members. + :vartype required_members: list[str] + :ivar required_zone_names: Required Zone Names. + :vartype required_zone_names: list[str] """ _attribute_map = { @@ -1170,6 +1374,20 @@ def __init__( required_zone_names: Optional[List[str]] = None, **kwargs ): + """ + :keyword id: Fully qualified identifier of the resource. + :paramtype id: str + :keyword name: Name of the resource. + :paramtype name: str + :keyword type: Type of the resource. + :paramtype type: str + :keyword group_id: + :paramtype group_id: str + :keyword required_members: Required Members. + :paramtype required_members: list[str] + :keyword required_zone_names: Required Zone Names. + :paramtype required_zone_names: list[str] + """ super(PrivateLinkResource, self).__init__(**kwargs) self.id = id self.name = name @@ -1182,10 +1400,10 @@ def __init__( class PrivateLinkResourcesListResult(msrest.serialization.Model): """Result of the List private link resources operation. - :param value: A collection of private link resources. - :type value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateLinkResource] - :param next_link: A link for the next page of private link resources. - :type next_link: str + :ivar value: A collection of private link resources. + :vartype value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateLinkResource] + :ivar next_link: A link for the next page of private link resources. + :vartype next_link: str """ _attribute_map = { @@ -1200,6 +1418,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: A collection of private link resources. + :paramtype value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateLinkResource] + :keyword next_link: A link for the next page of private link resources. + :paramtype next_link: str + """ super(PrivateLinkResourcesListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1210,12 +1434,12 @@ class RegenerateAccessKeyParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param key_type: Required. The access key to regenerate. Possible values include: "PrimaryKey", + :ivar key_type: Required. The access key to regenerate. Possible values include: "PrimaryKey", "SecondaryKey". - :type key_type: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.KeyType - :param key: Optional, if the key value provided, is reset for KeyType value or autogenerate Key + :vartype key_type: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.KeyType + :ivar key: Optional, if the key value provided, is reset for KeyType value or autogenerate Key value set for keyType. - :type key: str + :vartype key: str """ _validation = { @@ -1234,6 +1458,14 @@ def __init__( key: Optional[str] = None, **kwargs ): + """ + :keyword key_type: Required. The access key to regenerate. Possible values include: + "PrimaryKey", "SecondaryKey". + :paramtype key_type: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.KeyType + :keyword key: Optional, if the key value provided, is reset for KeyType value or autogenerate + Key value set for keyType. + :paramtype key: str + """ super(RegenerateAccessKeyParameters, self).__init__(**kwargs) self.key_type = key_type self.key = key @@ -1250,10 +1482,10 @@ class ResourceNamespacePatch(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -1277,6 +1509,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(ResourceNamespacePatch, self).__init__(**kwargs) self.location = location self.tags = tags @@ -1295,16 +1533,17 @@ class Rule(Resource): :vartype type: str :ivar system_data: The system meta data relating to this resource. :vartype system_data: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SystemData - :param action: Represents the filter actions which are allowed for the transformation of a + :ivar action: Represents the filter actions which are allowed for the transformation of a message that have been matched by a filter expression. - :type action: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Action - :param filter_type: Filter type that is evaluated against a BrokeredMessage. Possible values + :vartype action: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Action + :ivar filter_type: Filter type that is evaluated against a BrokeredMessage. Possible values include: "SqlFilter", "CorrelationFilter". - :type filter_type: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.FilterType - :param sql_filter: Properties of sqlFilter. - :type sql_filter: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SqlFilter - :param correlation_filter: Properties of correlationFilter. - :type correlation_filter: ~azure.mgmt.servicebus.v2021_06_01_preview.models.CorrelationFilter + :vartype filter_type: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.FilterType + :ivar sql_filter: Properties of sqlFilter. + :vartype sql_filter: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SqlFilter + :ivar correlation_filter: Properties of correlationFilter. + :vartype correlation_filter: + ~azure.mgmt.servicebus.v2021_06_01_preview.models.CorrelationFilter """ _validation = { @@ -1334,6 +1573,19 @@ def __init__( correlation_filter: Optional["CorrelationFilter"] = None, **kwargs ): + """ + :keyword action: Represents the filter actions which are allowed for the transformation of a + message that have been matched by a filter expression. + :paramtype action: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Action + :keyword filter_type: Filter type that is evaluated against a BrokeredMessage. Possible values + include: "SqlFilter", "CorrelationFilter". + :paramtype filter_type: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.FilterType + :keyword sql_filter: Properties of sqlFilter. + :paramtype sql_filter: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SqlFilter + :keyword correlation_filter: Properties of correlationFilter. + :paramtype correlation_filter: + ~azure.mgmt.servicebus.v2021_06_01_preview.models.CorrelationFilter + """ super(Rule, self).__init__(**kwargs) self.system_data = None self.action = action @@ -1345,11 +1597,11 @@ def __init__( class RuleListResult(msrest.serialization.Model): """The response of the List rule operation. - :param value: Result of the List Rules operation. - :type value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.Rule] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list + :ivar value: Result of the List Rules operation. + :vartype value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.Rule] + :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of rules. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -1364,6 +1616,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of the List Rules operation. + :paramtype value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.Rule] + :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete + list of rules. + :paramtype next_link: str + """ super(RuleListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1382,8 +1641,8 @@ class SBAuthorizationRule(Resource): :vartype type: str :ivar system_data: The system meta data relating to this resource. :vartype system_data: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SystemData - :param rights: The rights associated with the rule. - :type rights: list[str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessRights] + :ivar rights: The rights associated with the rule. + :vartype rights: list[str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessRights] """ _validation = { @@ -1407,6 +1666,10 @@ def __init__( rights: Optional[List[Union[str, "AccessRights"]]] = None, **kwargs ): + """ + :keyword rights: The rights associated with the rule. + :paramtype rights: list[str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessRights] + """ super(SBAuthorizationRule, self).__init__(**kwargs) self.system_data = None self.rights = rights @@ -1415,11 +1678,11 @@ def __init__( class SBAuthorizationRuleListResult(msrest.serialization.Model): """The response to the List Namespace operation. - :param value: Result of the List Authorization Rules operation. - :type value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list + :ivar value: Result of the List Authorization Rules operation. + :vartype value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule] + :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of Authorization Rules. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -1434,6 +1697,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of the List Authorization Rules operation. + :paramtype value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule] + :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete + list of Authorization Rules. + :paramtype next_link: str + """ super(SBAuthorizationRuleListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1442,15 +1712,15 @@ def __init__( class SBClientAffineProperties(msrest.serialization.Model): """Properties specific to client affine subscriptions. - :param client_id: Indicates the Client ID of the application that created the client-affine + :ivar client_id: Indicates the Client ID of the application that created the client-affine subscription. - :type client_id: str - :param is_durable: For client-affine subscriptions, this value indicates whether the + :vartype client_id: str + :ivar is_durable: For client-affine subscriptions, this value indicates whether the subscription is durable or not. - :type is_durable: bool - :param is_shared: For client-affine subscriptions, this value indicates whether the - subscription is shared or not. - :type is_shared: bool + :vartype is_durable: bool + :ivar is_shared: For client-affine subscriptions, this value indicates whether the subscription + is shared or not. + :vartype is_shared: bool """ _attribute_map = { @@ -1467,6 +1737,17 @@ def __init__( is_shared: Optional[bool] = None, **kwargs ): + """ + :keyword client_id: Indicates the Client ID of the application that created the client-affine + subscription. + :paramtype client_id: str + :keyword is_durable: For client-affine subscriptions, this value indicates whether the + subscription is durable or not. + :paramtype is_durable: bool + :keyword is_shared: For client-affine subscriptions, this value indicates whether the + subscription is shared or not. + :paramtype is_shared: bool + """ super(SBClientAffineProperties, self).__init__(**kwargs) self.client_id = client_id self.is_durable = is_durable @@ -1486,10 +1767,10 @@ class TrackedResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Required. The Geo-location where the resource lives. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Required. The Geo-location where the resource lives. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -1514,6 +1795,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. The Geo-location where the resource lives. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(TrackedResource, self).__init__(**kwargs) self.location = location self.tags = tags @@ -1532,14 +1819,14 @@ class SBNamespace(TrackedResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Required. The Geo-location where the resource lives. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param sku: Properties of SKU. - :type sku: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSku - :param identity: Properties of BYOK Identity description. - :type identity: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Identity + :ivar location: Required. The Geo-location where the resource lives. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar sku: Properties of SKU. + :vartype sku: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSku + :ivar identity: Properties of BYOK Identity description. + :vartype identity: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Identity :ivar system_data: The system meta data relating to this resource. :vartype system_data: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SystemData :ivar provisioning_state: Provisioning state of the namespace. @@ -1554,17 +1841,17 @@ class SBNamespace(TrackedResource): :vartype service_bus_endpoint: str :ivar metric_id: Identifier for Azure Insights metrics. :vartype metric_id: str - :param zone_redundant: Enabling this property creates a Premium Service Bus Namespace in - regions supported availability zones. - :type zone_redundant: bool - :param encryption: Properties of BYOK Encryption description. - :type encryption: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Encryption - :param private_endpoint_connections: List of private endpoint connections. - :type private_endpoint_connections: + :ivar zone_redundant: Enabling this property creates a Premium Service Bus Namespace in regions + supported availability zones. + :vartype zone_redundant: bool + :ivar encryption: Properties of BYOK Encryption description. + :vartype encryption: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Encryption + :ivar private_endpoint_connections: List of private endpoint connections. + :vartype private_endpoint_connections: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateEndpointConnection] - :param disable_local_auth: This property disables SAS authentication for the Service Bus + :ivar disable_local_auth: This property disables SAS authentication for the Service Bus namespace. - :type disable_local_auth: bool + :vartype disable_local_auth: bool """ _validation = { @@ -1615,6 +1902,27 @@ def __init__( disable_local_auth: Optional[bool] = None, **kwargs ): + """ + :keyword location: Required. The Geo-location where the resource lives. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword sku: Properties of SKU. + :paramtype sku: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSku + :keyword identity: Properties of BYOK Identity description. + :paramtype identity: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Identity + :keyword zone_redundant: Enabling this property creates a Premium Service Bus Namespace in + regions supported availability zones. + :paramtype zone_redundant: bool + :keyword encryption: Properties of BYOK Encryption description. + :paramtype encryption: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Encryption + :keyword private_endpoint_connections: List of private endpoint connections. + :paramtype private_endpoint_connections: + list[~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateEndpointConnection] + :keyword disable_local_auth: This property disables SAS authentication for the Service Bus + namespace. + :paramtype disable_local_auth: bool + """ super(SBNamespace, self).__init__(location=location, tags=tags, **kwargs) self.sku = sku self.identity = identity @@ -1634,11 +1942,11 @@ def __init__( class SBNamespaceListResult(msrest.serialization.Model): """The response of the List Namespace operation. - :param value: Result of the List Namespace operation. - :type value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list + :ivar value: Result of the List Namespace operation. + :vartype value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace] + :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of Namespaces. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -1653,6 +1961,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of the List Namespace operation. + :paramtype value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace] + :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete + list of Namespaces. + :paramtype next_link: str + """ super(SBNamespaceListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1669,14 +1984,14 @@ class SBNamespaceUpdateParameters(ResourceNamespacePatch): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param sku: Properties of SKU. - :type sku: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSku - :param identity: Properties of BYOK Identity description. - :type identity: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Identity + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar sku: Properties of SKU. + :vartype sku: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSku + :ivar identity: Properties of BYOK Identity description. + :vartype identity: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Identity :ivar provisioning_state: Provisioning state of the namespace. :vartype provisioning_state: str :ivar status: Status of the namespace. @@ -1689,17 +2004,17 @@ class SBNamespaceUpdateParameters(ResourceNamespacePatch): :vartype service_bus_endpoint: str :ivar metric_id: Identifier for Azure Insights metrics. :vartype metric_id: str - :param zone_redundant: Enabling this property creates a Premium Service Bus Namespace in - regions supported availability zones. - :type zone_redundant: bool - :param encryption: Properties of BYOK Encryption description. - :type encryption: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Encryption - :param private_endpoint_connections: List of private endpoint connections. - :type private_endpoint_connections: + :ivar zone_redundant: Enabling this property creates a Premium Service Bus Namespace in regions + supported availability zones. + :vartype zone_redundant: bool + :ivar encryption: Properties of BYOK Encryption description. + :vartype encryption: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Encryption + :ivar private_endpoint_connections: List of private endpoint connections. + :vartype private_endpoint_connections: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateEndpointConnection] - :param disable_local_auth: This property disables SAS authentication for the Service Bus + :ivar disable_local_auth: This property disables SAS authentication for the Service Bus namespace. - :type disable_local_auth: bool + :vartype disable_local_auth: bool """ _validation = { @@ -1747,6 +2062,27 @@ def __init__( disable_local_auth: Optional[bool] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword sku: Properties of SKU. + :paramtype sku: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSku + :keyword identity: Properties of BYOK Identity description. + :paramtype identity: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Identity + :keyword zone_redundant: Enabling this property creates a Premium Service Bus Namespace in + regions supported availability zones. + :paramtype zone_redundant: bool + :keyword encryption: Properties of BYOK Encryption description. + :paramtype encryption: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Encryption + :keyword private_endpoint_connections: List of private endpoint connections. + :paramtype private_endpoint_connections: + list[~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateEndpointConnection] + :keyword disable_local_auth: This property disables SAS authentication for the Service Bus + namespace. + :paramtype disable_local_auth: bool + """ super(SBNamespaceUpdateParameters, self).__init__(location=location, tags=tags, **kwargs) self.sku = sku self.identity = identity @@ -1788,55 +2124,55 @@ class SBQueue(Resource): :vartype size_in_bytes: long :ivar message_count: The number of messages in the queue. :vartype message_count: long - :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. Default is 1024. - :type max_size_in_megabytes: int - :param max_message_size_in_kilobytes: Maximum size (in KB) of the message payload that can be + :vartype max_size_in_megabytes: int + :ivar max_message_size_in_kilobytes: Maximum size (in KB) of the message payload that can be accepted by the queue. This property is only used in Premium today and default is 1024. - :type max_message_size_in_kilobytes: long - :param requires_duplicate_detection: A value indicating if this queue requires duplicate + :vartype max_message_size_in_kilobytes: long + :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 status: Enumerates the possible values for the status of a messaging entity. Possible + :vartype max_delivery_count: int + :ivar status: Enumerates the possible values for the status of a messaging entity. Possible values include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", "Deleting", "Renaming", "Unknown". - :type status: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.EntityStatus - :param enable_batched_operations: Value that indicates whether server-side batched operations + :vartype status: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.EntityStatus + :ivar enable_batched_operations: Value that indicates whether server-side batched operations are enabled. - :type enable_batched_operations: bool - :param auto_delete_on_idle: ISO 8061 timeSpan idle interval after which the queue is + :vartype enable_batched_operations: bool + :ivar auto_delete_on_idle: ISO 8061 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 enable_express: A value that indicates whether Express Entities are enabled. An express + :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 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_to: Queue/Topic name to forward the messages. - :type forward_to: str - :param forward_dead_lettered_messages_to: Queue/Topic name to forward the Dead Letter message. - :type forward_dead_lettered_messages_to: str + :vartype enable_express: bool + :ivar forward_to: Queue/Topic name to forward the messages. + :vartype forward_to: str + :ivar forward_dead_lettered_messages_to: Queue/Topic name to forward the Dead Letter message. + :vartype forward_dead_lettered_messages_to: str """ _validation = { @@ -1902,6 +2238,58 @@ def __init__( forward_dead_lettered_messages_to: Optional[str] = None, **kwargs ): + """ + :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. Default is 1024. + :paramtype max_size_in_megabytes: int + :keyword max_message_size_in_kilobytes: Maximum size (in KB) of the message payload that can be + accepted by the queue. This property is only used in Premium today and default is 1024. + :paramtype max_message_size_in_kilobytes: long + :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 status: Enumerates the possible values for the status of a messaging entity. Possible + values include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", + "Creating", "Deleting", "Renaming", "Unknown". + :paramtype status: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.EntityStatus + :keyword enable_batched_operations: Value that indicates whether server-side batched operations + are enabled. + :paramtype enable_batched_operations: bool + :keyword auto_delete_on_idle: ISO 8061 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 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_to: Queue/Topic name to forward the messages. + :paramtype forward_to: str + :keyword forward_dead_lettered_messages_to: Queue/Topic name to forward the Dead Letter + message. + :paramtype forward_dead_lettered_messages_to: str + """ super(SBQueue, self).__init__(**kwargs) self.system_data = None self.count_details = None @@ -1931,11 +2319,11 @@ def __init__( class SBQueueListResult(msrest.serialization.Model): """The response to the List Queues operation. - :param value: Result of the List Queues operation. - :type value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBQueue] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list + :ivar value: Result of the List Queues operation. + :vartype value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBQueue] + :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of queues. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -1950,6 +2338,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of the List Queues operation. + :paramtype value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBQueue] + :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete + list of queues. + :paramtype next_link: str + """ super(SBQueueListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1960,15 +2355,15 @@ class SBSku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. Name of this SKU. Possible values include: "Basic", "Standard", + :ivar name: Required. Name of this SKU. Possible values include: "Basic", "Standard", "Premium". - :type name: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.SkuName - :param tier: The billing tier of this particular SKU. Possible values include: "Basic", + :vartype name: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.SkuName + :ivar tier: The billing tier of this particular SKU. Possible values include: "Basic", "Standard", "Premium". - :type tier: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.SkuTier - :param capacity: The specified messaging units for the tier. For Premium tier, capacity are 1,2 + :vartype tier: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.SkuTier + :ivar capacity: The specified messaging units for the tier. For Premium tier, capacity are 1,2 and 4. - :type capacity: int + :vartype capacity: int """ _validation = { @@ -1989,6 +2384,17 @@ def __init__( capacity: Optional[int] = None, **kwargs ): + """ + :keyword name: Required. Name of this SKU. Possible values include: "Basic", "Standard", + "Premium". + :paramtype name: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.SkuName + :keyword tier: The billing tier of this particular SKU. Possible values include: "Basic", + "Standard", "Premium". + :paramtype tier: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.SkuTier + :keyword capacity: The specified messaging units for the tier. For Premium tier, capacity are + 1,2 and 4. + :paramtype capacity: int + """ super(SBSku, self).__init__(**kwargs) self.name = name self.tier = tier @@ -2018,45 +2424,45 @@ class SBSubscription(Resource): :vartype updated_at: ~datetime.datetime :ivar count_details: Message count details. :vartype count_details: ~azure.mgmt.servicebus.v2021_06_01_preview.models.MessageCountDetails - :param lock_duration: ISO 8061 lock duration timespan for the subscription. The default value - is 1 minute. - :type lock_duration: ~datetime.timedelta - :param requires_session: Value indicating if a subscription supports the concept of sessions. - :type requires_session: bool - :param default_message_time_to_live: ISO 8061 Default message timespan to live value. This is + :ivar lock_duration: ISO 8061 lock duration timespan for the subscription. The default value is + 1 minute. + :vartype lock_duration: ~datetime.timedelta + :ivar requires_session: Value indicating if a subscription supports the concept of sessions. + :vartype requires_session: bool + :ivar default_message_time_to_live: ISO 8061 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_filter_evaluation_exceptions: Value that indicates whether a + :vartype default_message_time_to_live: ~datetime.timedelta + :ivar dead_lettering_on_filter_evaluation_exceptions: Value that indicates whether a subscription has dead letter support on filter evaluation exceptions. - :type dead_lettering_on_filter_evaluation_exceptions: bool - :param dead_lettering_on_message_expiration: Value that indicates whether a subscription has + :vartype dead_lettering_on_filter_evaluation_exceptions: bool + :ivar dead_lettering_on_message_expiration: Value that indicates whether a subscription 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: Number of maximum deliveries. - :type max_delivery_count: int - :param status: Enumerates the possible values for the status of a messaging entity. Possible + :vartype duplicate_detection_history_time_window: ~datetime.timedelta + :ivar max_delivery_count: Number of maximum deliveries. + :vartype max_delivery_count: int + :ivar status: Enumerates the possible values for the status of a messaging entity. Possible values include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", "Deleting", "Renaming", "Unknown". - :type status: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.EntityStatus - :param enable_batched_operations: Value that indicates whether server-side batched operations + :vartype status: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.EntityStatus + :ivar enable_batched_operations: Value that indicates whether server-side batched operations are enabled. - :type enable_batched_operations: bool - :param auto_delete_on_idle: ISO 8061 timeSpan idle interval after which the topic is + :vartype enable_batched_operations: bool + :ivar auto_delete_on_idle: ISO 8061 timeSpan idle interval after which the topic is automatically deleted. The minimum duration is 5 minutes. - :type auto_delete_on_idle: ~datetime.timedelta - :param forward_to: Queue/Topic name to forward the messages. - :type forward_to: str - :param forward_dead_lettered_messages_to: Queue/Topic name to forward the Dead Letter message. - :type forward_dead_lettered_messages_to: str - :param is_client_affine: Value that indicates whether the subscription has an affinity to the + :vartype auto_delete_on_idle: ~datetime.timedelta + :ivar forward_to: Queue/Topic name to forward the messages. + :vartype forward_to: str + :ivar forward_dead_lettered_messages_to: Queue/Topic name to forward the Dead Letter message. + :vartype forward_dead_lettered_messages_to: str + :ivar is_client_affine: Value that indicates whether the subscription has an affinity to the client id. - :type is_client_affine: bool - :param client_affine_properties: Properties specific to client affine subscriptions. - :type client_affine_properties: + :vartype is_client_affine: bool + :ivar client_affine_properties: Properties specific to client affine subscriptions. + :vartype client_affine_properties: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBClientAffineProperties """ @@ -2117,6 +2523,49 @@ def __init__( client_affine_properties: Optional["SBClientAffineProperties"] = None, **kwargs ): + """ + :keyword lock_duration: ISO 8061 lock duration timespan for the subscription. The default value + is 1 minute. + :paramtype lock_duration: ~datetime.timedelta + :keyword requires_session: Value indicating if a subscription supports the concept of sessions. + :paramtype requires_session: bool + :keyword default_message_time_to_live: ISO 8061 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_filter_evaluation_exceptions: Value that indicates whether a + subscription has dead letter support on filter evaluation exceptions. + :paramtype dead_lettering_on_filter_evaluation_exceptions: bool + :keyword dead_lettering_on_message_expiration: Value that indicates whether a subscription 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: Number of maximum deliveries. + :paramtype max_delivery_count: int + :keyword status: Enumerates the possible values for the status of a messaging entity. Possible + values include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", + "Creating", "Deleting", "Renaming", "Unknown". + :paramtype status: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.EntityStatus + :keyword enable_batched_operations: Value that indicates whether server-side batched operations + are enabled. + :paramtype enable_batched_operations: bool + :keyword auto_delete_on_idle: ISO 8061 timeSpan idle interval after which the topic is + automatically deleted. The minimum duration is 5 minutes. + :paramtype auto_delete_on_idle: ~datetime.timedelta + :keyword forward_to: Queue/Topic name to forward the messages. + :paramtype forward_to: str + :keyword forward_dead_lettered_messages_to: Queue/Topic name to forward the Dead Letter + message. + :paramtype forward_dead_lettered_messages_to: str + :keyword is_client_affine: Value that indicates whether the subscription has an affinity to the + client id. + :paramtype is_client_affine: bool + :keyword client_affine_properties: Properties specific to client affine subscriptions. + :paramtype client_affine_properties: + ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBClientAffineProperties + """ super(SBSubscription, self).__init__(**kwargs) self.system_data = None self.message_count = None @@ -2143,11 +2592,11 @@ def __init__( class SBSubscriptionListResult(msrest.serialization.Model): """The response to the List Subscriptions operation. - :param value: Result of the List Subscriptions operation. - :type value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSubscription] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list + :ivar value: Result of the List Subscriptions operation. + :vartype value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSubscription] + :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of subscriptions. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -2162,6 +2611,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of the List Subscriptions operation. + :paramtype value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSubscription] + :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete + list of subscriptions. + :paramtype next_link: str + """ super(SBSubscriptionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -2192,40 +2648,40 @@ class SBTopic(Resource): :vartype subscription_count: int :ivar count_details: Message count details. :vartype count_details: ~azure.mgmt.servicebus.v2021_06_01_preview.models.MessageCountDetails - :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: Maximum size of the topic in megabytes, which is the size of the + :vartype default_message_time_to_live: ~datetime.timedelta + :ivar max_size_in_megabytes: Maximum size of the topic in megabytes, which is the size of the memory allocated for the topic. Default is 1024. - :type max_size_in_megabytes: int - :param max_message_size_in_kilobytes: Maximum size (in KB) of the message payload that can be + :vartype max_size_in_megabytes: int + :ivar max_message_size_in_kilobytes: Maximum size (in KB) of the message payload that can be accepted by the topic. This property is only used in Premium today and default is 1024. - :type max_message_size_in_kilobytes: long - :param requires_duplicate_detection: Value indicating if this topic requires duplicate + :vartype max_message_size_in_kilobytes: long + :ivar requires_duplicate_detection: Value indicating if this topic requires duplicate detection. - :type requires_duplicate_detection: bool - :param duplicate_detection_history_time_window: ISO8601 timespan structure that defines the + :vartype requires_duplicate_detection: bool + :ivar duplicate_detection_history_time_window: ISO8601 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 status: Enumerates the possible values for the status of a messaging entity. Possible + :vartype enable_batched_operations: bool + :ivar status: Enumerates the possible values for the status of a messaging entity. Possible values include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", "Deleting", "Renaming", "Unknown". - :type status: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.EntityStatus - :param support_ordering: Value that indicates whether the topic supports ordering. - :type support_ordering: bool - :param auto_delete_on_idle: ISO 8601 timespan idle interval after which the topic is + :vartype status: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.EntityStatus + :ivar support_ordering: Value that indicates whether the topic supports ordering. + :vartype support_ordering: bool + :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: Value that indicates whether the topic to be partitioned across + :vartype auto_delete_on_idle: ~datetime.timedelta + :ivar enable_partitioning: Value that indicates whether the topic to be partitioned across multiple message brokers is enabled. - :type enable_partitioning: bool - :param enable_express: Value that indicates whether Express Entities are enabled. An express + :vartype enable_partitioning: bool + :ivar enable_express: 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 + :vartype enable_express: bool """ _validation = { @@ -2281,6 +2737,42 @@ def __init__( enable_express: Optional[bool] = None, **kwargs ): + """ + :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: Maximum size of the topic in megabytes, which is the size of + the memory allocated for the topic. Default is 1024. + :paramtype max_size_in_megabytes: int + :keyword max_message_size_in_kilobytes: Maximum size (in KB) of the message payload that can be + accepted by the topic. This property is only used in Premium today and default is 1024. + :paramtype max_message_size_in_kilobytes: long + :keyword requires_duplicate_detection: Value indicating if this topic requires duplicate + detection. + :paramtype requires_duplicate_detection: bool + :keyword duplicate_detection_history_time_window: ISO8601 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 status: Enumerates the possible values for the status of a messaging entity. Possible + values include: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", + "Creating", "Deleting", "Renaming", "Unknown". + :paramtype status: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.EntityStatus + :keyword support_ordering: Value that indicates whether the topic supports ordering. + :paramtype support_ordering: bool + :keyword auto_delete_on_idle: ISO 8601 timespan idle interval after which the topic is + automatically deleted. The minimum duration is 5 minutes. + :paramtype auto_delete_on_idle: ~datetime.timedelta + :keyword enable_partitioning: Value that indicates whether the topic to be partitioned across + multiple message brokers is enabled. + :paramtype enable_partitioning: bool + :keyword enable_express: 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 + """ super(SBTopic, self).__init__(**kwargs) self.system_data = None self.size_in_bytes = None @@ -2305,11 +2797,11 @@ def __init__( class SBTopicListResult(msrest.serialization.Model): """The response to the List Topics operation. - :param value: Result of the List Topics operation. - :type value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBTopic] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list + :ivar value: Result of the List Topics operation. + :vartype value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBTopic] + :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of topics. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -2324,6 +2816,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of the List Topics operation. + :paramtype value: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBTopic] + :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete + list of topics. + :paramtype next_link: str + """ super(SBTopicListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -2332,14 +2831,14 @@ def __init__( class SqlFilter(msrest.serialization.Model): """Represents a filter which is a composition of an expression and an action that is executed in the pub/sub pipeline. - :param sql_expression: The SQL expression. e.g. MyProperty='ABC'. - :type sql_expression: str - :param compatibility_level: This property is reserved for future use. An integer value showing + :ivar sql_expression: The SQL expression. e.g. MyProperty='ABC'. + :vartype sql_expression: str + :ivar compatibility_level: This property is reserved for future use. An integer value showing the compatibility level, currently hard-coded to 20. - :type compatibility_level: int - :param requires_preprocessing: Value that indicates whether the rule action requires + :vartype compatibility_level: int + :ivar requires_preprocessing: Value that indicates whether the rule action requires preprocessing. - :type requires_preprocessing: bool + :vartype requires_preprocessing: bool """ _attribute_map = { @@ -2356,6 +2855,16 @@ def __init__( requires_preprocessing: Optional[bool] = True, **kwargs ): + """ + :keyword sql_expression: The SQL expression. e.g. MyProperty='ABC'. + :paramtype sql_expression: str + :keyword compatibility_level: This property is reserved for future use. An integer value + showing the compatibility level, currently hard-coded to 20. + :paramtype compatibility_level: int + :keyword requires_preprocessing: Value that indicates whether the rule action requires + preprocessing. + :paramtype requires_preprocessing: bool + """ super(SqlFilter, self).__init__(**kwargs) self.sql_expression = sql_expression self.compatibility_level = compatibility_level @@ -2365,14 +2874,14 @@ def __init__( class SqlRuleAction(Action): """Represents set of actions written in SQL language-based syntax that is performed against a ServiceBus.Messaging.BrokeredMessage. - :param sql_expression: SQL expression. e.g. MyProperty='ABC'. - :type sql_expression: str - :param compatibility_level: This property is reserved for future use. An integer value showing + :ivar sql_expression: SQL expression. e.g. MyProperty='ABC'. + :vartype sql_expression: str + :ivar compatibility_level: This property is reserved for future use. An integer value showing the compatibility level, currently hard-coded to 20. - :type compatibility_level: int - :param requires_preprocessing: Value that indicates whether the rule action requires + :vartype compatibility_level: int + :ivar requires_preprocessing: Value that indicates whether the rule action requires preprocessing. - :type requires_preprocessing: bool + :vartype requires_preprocessing: bool """ _attribute_map = { @@ -2389,6 +2898,16 @@ def __init__( requires_preprocessing: Optional[bool] = True, **kwargs ): + """ + :keyword sql_expression: SQL expression. e.g. MyProperty='ABC'. + :paramtype sql_expression: str + :keyword compatibility_level: This property is reserved for future use. An integer value + showing the compatibility level, currently hard-coded to 20. + :paramtype compatibility_level: int + :keyword requires_preprocessing: Value that indicates whether the rule action requires + preprocessing. + :paramtype requires_preprocessing: bool + """ super(SqlRuleAction, self).__init__(sql_expression=sql_expression, compatibility_level=compatibility_level, requires_preprocessing=requires_preprocessing, **kwargs) @@ -2397,8 +2916,8 @@ class Subnet(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Required. Resource ID of Virtual Network Subnet. - :type id: str + :ivar id: Required. Resource ID of Virtual Network Subnet. + :vartype id: str """ _validation = { @@ -2415,6 +2934,10 @@ def __init__( id: str, **kwargs ): + """ + :keyword id: Required. Resource ID of Virtual Network Subnet. + :paramtype id: str + """ super(Subnet, self).__init__(**kwargs) self.id = id @@ -2422,21 +2945,22 @@ def __init__( class SystemData(msrest.serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or + ~azure.mgmt.servicebus.v2021_06_01_preview.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or + :vartype last_modified_by_type: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.CreatedByType - :param last_modified_at: The type of identity that last modified the resource. - :type last_modified_at: ~datetime.datetime + :ivar last_modified_at: The type of identity that last modified the resource. + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -2459,6 +2983,24 @@ def __init__( last_modified_at: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or + ~azure.mgmt.servicebus.v2021_06_01_preview.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or + ~azure.mgmt.servicebus.v2021_06_01_preview.models.CreatedByType + :keyword last_modified_at: The type of identity that last modified the resource. + :paramtype last_modified_at: ~datetime.datetime + """ super(SystemData, self).__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type @@ -2493,6 +3035,8 @@ def __init__( self, **kwargs ): + """ + """ super(UserAssignedIdentity, self).__init__(**kwargs) self.principal_id = None self.client_id = None @@ -2501,8 +3045,8 @@ def __init__( class UserAssignedIdentityProperties(msrest.serialization.Model): """UserAssignedIdentityProperties. - :param user_assigned_identity: ARM ID of user Identity selected for encryption. - :type user_assigned_identity: str + :ivar user_assigned_identity: ARM ID of user Identity selected for encryption. + :vartype user_assigned_identity: str """ _attribute_map = { @@ -2515,5 +3059,9 @@ def __init__( user_assigned_identity: Optional[str] = None, **kwargs ): + """ + :keyword user_assigned_identity: ARM ID of user Identity selected for encryption. + :paramtype user_assigned_identity: str + """ super(UserAssignedIdentityProperties, self).__init__(**kwargs) self.user_assigned_identity = user_assigned_identity diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/models/_service_bus_management_client_enums.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/models/_service_bus_management_client_enums.py index 7123c5495c09..4fdd593c08f5 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/models/_service_bus_management_client_enums.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/models/_service_bus_management_client_enums.py @@ -6,33 +6,18 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AccessRights(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MANAGE = "Manage" SEND = "Send" LISTEN = "Listen" -class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of identity that created the resource. """ @@ -41,14 +26,14 @@ class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class DefaultAction(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DefaultAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Default Action for Network Rule Set """ ALLOW = "Allow" DENY = "Deny" -class EndPointProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class EndPointProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Provisioning state of the Private Endpoint Connection. """ @@ -59,7 +44,7 @@ class EndPointProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, En CANCELED = "Canceled" FAILED = "Failed" -class EntityStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class EntityStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Entity status. """ @@ -73,21 +58,21 @@ class EntityStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): RENAMING = "Renaming" UNKNOWN = "Unknown" -class FilterType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class FilterType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Rule filter types """ SQL_FILTER = "SqlFilter" CORRELATION_FILTER = "CorrelationFilter" -class KeyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class KeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The access key to regenerate. """ PRIMARY_KEY = "PrimaryKey" SECONDARY_KEY = "SecondaryKey" -class ManagedServiceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ManagedServiceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of managed service identity. """ @@ -96,17 +81,17 @@ class ManagedServiceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, E SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class MigrationConfigurationName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class MigrationConfigurationName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): _DEFAULT = "$default" -class NetworkRuleIPAction(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class NetworkRuleIPAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The IP Filter Action """ ALLOW = "Allow" -class PrivateLinkConnectionStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PrivateLinkConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Status of the connection. """ @@ -115,7 +100,7 @@ class PrivateLinkConnectionStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, REJECTED = "Rejected" DISCONNECTED = "Disconnected" -class ProvisioningStateDR(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningStateDR(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Provisioning state of the Alias(Disaster Recovery configuration) - possible values 'Accepted' or 'Succeeded' or 'Failed' """ @@ -124,14 +109,14 @@ class ProvisioningStateDR(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" FAILED = "Failed" -class PublicNetworkAccessFlag(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PublicNetworkAccessFlag(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """This determines if traffic is allowed over public network. By default it is enabled. """ ENABLED = "Enabled" DISABLED = "Disabled" -class RoleDisasterRecovery(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RoleDisasterRecovery(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """role of namespace in GEO DR - possible values 'Primary' or 'PrimaryNotReplicating' or 'Secondary' """ @@ -140,7 +125,7 @@ class RoleDisasterRecovery(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PRIMARY_NOT_REPLICATING = "PrimaryNotReplicating" SECONDARY = "Secondary" -class SkuName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Name of this SKU. """ @@ -148,7 +133,7 @@ class SkuName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): STANDARD = "Standard" PREMIUM = "Premium" -class SkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The billing tier of this particular SKU. """ @@ -156,7 +141,7 @@ class SkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): STANDARD = "Standard" PREMIUM = "Premium" -class UnavailableReason(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class UnavailableReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Specifies the reason for the unavailability of the service. """ diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_disaster_recovery_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_disaster_recovery_configs_operations.py index 565e5f07be20..a0e2a1f3433d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_disaster_recovery_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_disaster_recovery_configs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,429 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_check_name_availability_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + namespace_name: str, + alias: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + namespace_name: str, + alias: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + namespace_name: str, + alias: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_break_pairing_request( + resource_group_name: str, + namespace_name: str, + alias: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_fail_over_request( + resource_group_name: str, + namespace_name: str, + alias: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_authorization_rules_request( + resource_group_name: str, + namespace_name: str, + alias: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + alias: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_keys_request( + resource_group_name: str, + namespace_name: str, + alias: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "alias": _SERIALIZER.url("alias", alias, 'str', max_length=50, min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class DisasterRecoveryConfigsOperations(object): """DisasterRecoveryConfigsOperations operations. @@ -45,14 +452,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def check_name_availability( self, - resource_group_name, # type: str - namespace_name, # type: str - parameters, # type: "_models.CheckNameAvailability" - **kwargs # type: Any - ): - # type: (...) -> "_models.CheckNameAvailabilityResult" + resource_group_name: str, + namespace_name: str, + parameters: "_models.CheckNameAvailability", + **kwargs: Any + ) -> "_models.CheckNameAvailabilityResult": """Check the give namespace name availability. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -71,38 +478,34 @@ def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CheckNameAvailability') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'CheckNameAvailability') + + request = build_check_name_availability_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) @@ -111,15 +514,17 @@ def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability"} # type: ignore + + + @distributed_trace def list( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ArmDisasterRecoveryListResult"] + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> Iterable["_models.ArmDisasterRecoveryListResult"]: """Gets all Alias(Disaster Recovery configurations). :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -127,45 +532,48 @@ def list( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ArmDisasterRecoveryListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.ArmDisasterRecoveryListResult] + :return: An iterator like instance of either ArmDisasterRecoveryListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.ArmDisasterRecoveryListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ArmDisasterRecoveryListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ArmDisasterRecoveryListResult', pipeline_response) + deserialized = self._deserialize("ArmDisasterRecoveryListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -174,30 +582,35 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs"} # type: ignore + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - namespace_name, # type: str - alias, # type: str - parameters, # type: "_models.ArmDisasterRecovery" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ArmDisasterRecovery"] + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: "_models.ArmDisasterRecovery", + **kwargs: Any + ) -> Optional["_models.ArmDisasterRecovery"]: """Creates or updates a new Alias(Disaster Recovery configuration). :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -218,39 +631,35 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ArmDisasterRecovery') - 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) + + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ArmDisasterRecovery') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -261,16 +670,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}'} # type: ignore - def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - alias, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + alias: str, + **kwargs: Any + ) -> None: """Deletes an Alias(Disaster Recovery configuration). :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -289,49 +700,47 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - namespace_name, # type: str - alias, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ArmDisasterRecovery" + resource_group_name: str, + namespace_name: str, + alias: str, + **kwargs: Any + ) -> "_models.ArmDisasterRecovery": """Retrieves Alias(Disaster Recovery configuration) for primary or secondary namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -350,34 +759,31 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) @@ -386,16 +792,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}'} # type: ignore - def break_pairing( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}"} # type: ignore + + + @distributed_trace + def break_pairing( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - alias, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + alias: str, + **kwargs: Any + ) -> None: """This operation disables the Disaster Recovery and stops replicating changes from primary to secondary namespaces. @@ -415,50 +823,48 @@ def break_pairing( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.break_pairing.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_break_pairing_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.break_pairing.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - break_pairing.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing'} # type: ignore + break_pairing.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing"} # type: ignore + - def fail_over( + @distributed_trace + def fail_over( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - alias, # type: str - parameters=None, # type: Optional["_models.FailoverProperties"] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional["_models.FailoverProperties"] = None, + **kwargs: Any + ) -> None: """Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -468,6 +874,7 @@ def fail_over( :param alias: The Disaster Recovery configuration name. :type alias: str :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Default value is None. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.FailoverProperties :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) @@ -479,57 +886,54 @@ def fail_over( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.fail_over.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if parameters is not None: - body_content = self._serialize.body(parameters, 'FailoverProperties') + _json = self._serialize.body(parameters, 'FailoverProperties') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + _json = None + + request = build_fail_over_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.fail_over.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - fail_over.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover'} # type: ignore + fail_over.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover"} # type: ignore + + @distributed_trace def list_authorization_rules( self, - resource_group_name, # type: str - namespace_name, # type: str - alias, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SBAuthorizationRuleListResult"] + resource_group_name: str, + namespace_name: str, + alias: str, + **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRuleListResult"]: """Gets the authorization rules for a namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -539,46 +943,50 @@ def list_authorization_rules( :param alias: The Disaster Recovery configuration name. :type alias: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRuleListResult] + :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SBAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -587,30 +995,35 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules"} # type: ignore + @distributed_trace def get_authorization_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - alias, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SBAuthorizationRule" + resource_group_name: str, + namespace_name: str, + alias: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.SBAuthorizationRule": """Gets an authorization rule for a namespace by rule name. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -631,35 +1044,32 @@ def get_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -668,17 +1078,19 @@ def get_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}'} # type: ignore + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace def list_keys( self, - resource_group_name, # type: str - namespace_name, # type: str - alias, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessKeys" + resource_group_name: str, + namespace_name: str, + alias: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.AccessKeys": """Gets the primary and secondary connection strings for the namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -699,35 +1111,32 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'alias': self._serialize.url("alias", alias, 'str', max_length=50, min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + alias=alias, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -736,4 +1145,6 @@ def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys'} # type: ignore + + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_migration_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_migration_configs_operations.py index eb40bd81f0d8..26e2da9c6a22 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_migration_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_migration_configs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,25 +6,261 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_and_start_migration_request_initial( + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_complete_migration_request( + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_revert_request( + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "configName": _SERIALIZER.url("config_name", config_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class MigrationConfigsOperations(object): """MigrationConfigsOperations operations. @@ -47,13 +284,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MigrationConfigListResult"] + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> Iterable["_models.MigrationConfigListResult"]: """Gets all migrationConfigurations. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -61,45 +298,48 @@ def list( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MigrationConfigListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigListResult] + :return: An iterator like instance of either MigrationConfigListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.MigrationConfigListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('MigrationConfigListResult', pipeline_response) + deserialized = self._deserialize("MigrationConfigListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -108,69 +348,68 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations"} # type: ignore def _create_and_start_migration_initial( self, - resource_group_name, # type: str - namespace_name, # type: str - config_name, # type: Union[str, "_models.MigrationConfigurationName"] - parameters, # type: "_models.MigrationConfigProperties" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.MigrationConfigProperties"] + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + parameters: "_models.MigrationConfigProperties", + **kwargs: Any + ) -> Optional["_models.MigrationConfigProperties"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.MigrationConfigProperties"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_and_start_migration_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'MigrationConfigProperties') - 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) + + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'MigrationConfigProperties') + + request = build_create_and_start_migration_request_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_and_start_migration_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -180,17 +419,19 @@ def _create_and_start_migration_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_and_start_migration_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}'} # type: ignore + _create_and_start_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + + + @distributed_trace def begin_create_and_start_migration( self, - resource_group_name, # type: str - namespace_name, # type: str - config_name, # type: Union[str, "_models.MigrationConfigurationName"] - parameters, # type: "_models.MigrationConfigProperties" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.MigrationConfigProperties"] + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + parameters: "_models.MigrationConfigProperties", + **kwargs: Any + ) -> LROPoller["_models.MigrationConfigProperties"]: """Creates Migration configuration and starts migration of entities from Standard to Premium namespace. @@ -199,19 +440,26 @@ def begin_create_and_start_migration( :param namespace_name: The namespace name. :type namespace_name: str :param config_name: The configuration name. Should always be "$default". - :type config_name: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigurationName + :type config_name: str or + ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigurationName :param parameters: Parameters required to create Migration Configuration. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigProperties :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either MigrationConfigProperties or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigProperties] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MigrationConfigProperties or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigProperties] + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.MigrationConfigProperties"] lro_delay = kwargs.pop( @@ -225,28 +473,22 @@ def begin_create_and_start_migration( namespace_name=namespace_name, config_name=config_name, parameters=parameters, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -256,18 +498,18 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_and_start_migration.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def delete( + begin_create_and_start_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - config_name, # type: Union[str, "_models.MigrationConfigurationName"] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + **kwargs: Any + ) -> None: """Deletes a MigrationConfiguration. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -275,7 +517,8 @@ def delete( :param namespace_name: The namespace name. :type namespace_name: str :param config_name: The configuration name. Should always be "$default". - :type config_name: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigurationName + :type config_name: str or + ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigurationName :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -286,49 +529,47 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - namespace_name, # type: str - config_name, # type: Union[str, "_models.MigrationConfigurationName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.MigrationConfigProperties" + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + **kwargs: Any + ) -> "_models.MigrationConfigProperties": """Retrieves Migration Config. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -336,7 +577,8 @@ def get( :param namespace_name: The namespace name. :type namespace_name: str :param config_name: The configuration name. Should always be "$default". - :type config_name: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigurationName + :type config_name: str or + ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigurationName :keyword callable cls: A custom type or function that will be passed the direct response :return: MigrationConfigProperties, or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigProperties @@ -347,34 +589,31 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) @@ -383,16 +622,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}'} # type: ignore - def complete_migration( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + + + @distributed_trace + def complete_migration( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - config_name, # type: Union[str, "_models.MigrationConfigurationName"] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + **kwargs: Any + ) -> None: """This operation Completes Migration of entities by pointing the connection strings to Premium namespace and any entities created after the operation will be under Premium Namespace. CompleteMigration operation will fail when entity migration is in-progress. @@ -402,7 +643,8 @@ def complete_migration( :param namespace_name: The namespace name. :type namespace_name: str :param config_name: The configuration name. Should always be "$default". - :type config_name: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigurationName + :type config_name: str or + ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigurationName :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -413,49 +655,47 @@ def complete_migration( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.complete_migration.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_complete_migration_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.complete_migration.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - complete_migration.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade'} # type: ignore + complete_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade"} # type: ignore - def revert( + + @distributed_trace + def revert( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - config_name, # type: Union[str, "_models.MigrationConfigurationName"] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + **kwargs: Any + ) -> None: """This operation reverts Migration. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -463,7 +703,8 @@ def revert( :param namespace_name: The namespace name. :type namespace_name: str :param config_name: The configuration name. Should always be "$default". - :type config_name: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigurationName + :type config_name: str or + ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigurationName :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -474,37 +715,35 @@ def revert( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.revert.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'configName': self._serialize.url("config_name", config_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_revert_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + config_name=config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.revert.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - revert.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert'} # type: ignore + revert.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_namespaces_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_namespaces_operations.py index 12241d61c1e1..57a1aff19cdc 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_namespaces_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_namespaces_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,25 +6,651 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_create_or_update_network_rule_set_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_network_rule_set_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_network_rule_sets_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_authorization_rules_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_keys_request( + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_regenerate_keys_request( + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_check_name_availability_request( + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) class NamespacesOperations(object): """NamespacesOperations operations. @@ -47,51 +674,52 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SBNamespaceListResult"] + **kwargs: Any + ) -> Iterable["_models.SBNamespaceListResult"]: """Gets all the available namespaces within the subscription, irrespective of the resource groups. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBNamespaceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespaceListResult] + :return: An iterator like instance of either SBNamespaceListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespaceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBNamespaceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SBNamespaceListResult', pipeline_response) + deserialized = self._deserialize("SBNamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -100,70 +728,77 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces"} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SBNamespaceListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.SBNamespaceListResult"]: """Gets the available namespaces within a resource group. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBNamespaceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespaceListResult] + :return: An iterator like instance of either SBNamespaceListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespaceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBNamespaceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SBNamespaceListResult', pipeline_response) + deserialized = self._deserialize("SBNamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -172,67 +807,66 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces"} # type: ignore def _create_or_update_initial( self, - resource_group_name, # type: str - namespace_name, # type: str - parameters, # type: "_models.SBNamespace" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.SBNamespace"] + resource_group_name: str, + namespace_name: str, + parameters: "_models.SBNamespace", + **kwargs: Any + ) -> Optional["_models.SBNamespace"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.SBNamespace"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBNamespace') - 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) + + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBNamespace') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -245,16 +879,18 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - namespace_name, # type: str - parameters, # type: "_models.SBNamespace" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.SBNamespace"] + resource_group_name: str, + namespace_name: str, + parameters: "_models.SBNamespace", + **kwargs: Any + ) -> LROPoller["_models.SBNamespace"]: """Creates or updates a service namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. @@ -266,14 +902,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either SBNamespace or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either SBNamespace or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace] + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.SBNamespace"] lro_delay = kwargs.pop( @@ -286,27 +928,22 @@ def begin_create_or_update( resource_group_name=resource_group_name, namespace_name=namespace_name, parameters=parameters, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('SBNamespace', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -316,63 +953,59 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def _delete_initial( + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + - def begin_delete( + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes an existing namespace. This operation also removes all associated resources under the namespace. @@ -382,14 +1015,17 @@ def begin_delete( :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( @@ -401,24 +1037,18 @@ def begin_delete( raw_result = self._delete_initial( resource_group_name=resource_group_name, namespace_name=namespace_name, + api_version=api_version, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -428,17 +1058,17 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SBNamespace" + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> "_models.SBNamespace": """Gets a description for the specified namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -455,33 +1085,30 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBNamespace', pipeline_response) @@ -490,16 +1117,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + + @distributed_trace def update( self, - resource_group_name, # type: str - namespace_name, # type: str - parameters, # type: "_models.SBNamespaceUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.SBNamespace"] + resource_group_name: str, + namespace_name: str, + parameters: "_models.SBNamespaceUpdateParameters", + **kwargs: Any + ) -> Optional["_models.SBNamespace"]: """Updates a service namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. @@ -519,38 +1148,34 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -564,16 +1189,18 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + + @distributed_trace def create_or_update_network_rule_set( self, - resource_group_name, # type: str - namespace_name, # type: str - parameters, # type: "_models.NetworkRuleSet" - **kwargs # type: Any - ): - # type: (...) -> "_models.NetworkRuleSet" + resource_group_name: str, + namespace_name: str, + parameters: "_models.NetworkRuleSet", + **kwargs: Any + ) -> "_models.NetworkRuleSet": """Create or update NetworkRuleSet for a Namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -592,38 +1219,34 @@ def create_or_update_network_rule_set( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_network_rule_set.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'NetworkRuleSet') - 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) + + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'NetworkRuleSet') + + request = build_create_or_update_network_rule_set_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_network_rule_set.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('NetworkRuleSet', pipeline_response) @@ -632,15 +1255,17 @@ def create_or_update_network_rule_set( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_network_rule_set.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default'} # type: ignore + create_or_update_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore + + + @distributed_trace def get_network_rule_set( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.NetworkRuleSet" + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> "_models.NetworkRuleSet": """Gets NetworkRuleSet for a Namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -657,33 +1282,30 @@ def get_network_rule_set( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_network_rule_set.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_network_rule_set_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_network_rule_set.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('NetworkRuleSet', pipeline_response) @@ -692,15 +1314,17 @@ def get_network_rule_set( return cls(pipeline_response, deserialized, {}) return deserialized - get_network_rule_set.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default'} # type: ignore + get_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore + + + @distributed_trace def list_network_rule_sets( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.NetworkRuleSetListResult"] + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> Iterable["_models.NetworkRuleSetListResult"]: """Gets list of NetworkRuleSet for a Namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -708,45 +1332,48 @@ def list_network_rule_sets( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NetworkRuleSetListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleSetListResult] + :return: An iterator like instance of either NetworkRuleSetListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkRuleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_network_rule_sets.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_network_rule_sets_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_network_rule_sets.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_network_rule_sets_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('NetworkRuleSetListResult', pipeline_response) + deserialized = self._deserialize("NetworkRuleSetListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -755,28 +1382,33 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_network_rule_sets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets'} # type: ignore + list_network_rule_sets.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets"} # type: ignore + @distributed_trace def list_authorization_rules( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SBAuthorizationRuleListResult"] + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRuleListResult"]: """Gets the authorization rules for a namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -784,45 +1416,48 @@ def list_authorization_rules( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRuleListResult] + :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SBAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -831,30 +1466,35 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules"} # type: ignore + @distributed_trace def create_or_update_authorization_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - authorization_rule_name, # type: str - parameters, # type: "_models.SBAuthorizationRule" - **kwargs # type: Any - ): - # type: (...) -> "_models.SBAuthorizationRule" + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: "_models.SBAuthorizationRule", + **kwargs: Any + ) -> "_models.SBAuthorizationRule": """Creates or updates an authorization rule for a namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -875,39 +1515,35 @@ def create_or_update_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBAuthorizationRule') - 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) + + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBAuthorizationRule') + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -916,16 +1552,18 @@ def create_or_update_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}'} # type: ignore - def delete_authorization_rule( + create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace + def delete_authorization_rule( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> None: """Deletes a namespace authorization rule. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -944,49 +1582,47 @@ def delete_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}'} # type: ignore + delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore + + @distributed_trace def get_authorization_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SBAuthorizationRule" + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.SBAuthorizationRule": """Gets an authorization rule for a namespace by rule name. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -1005,34 +1641,31 @@ def get_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -1041,16 +1674,18 @@ def get_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}'} # type: ignore + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace def list_keys( self, - resource_group_name, # type: str - namespace_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessKeys" + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.AccessKeys": """Gets the primary and secondary connection strings for the namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -1069,34 +1704,31 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -1105,17 +1737,19 @@ def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore + + + @distributed_trace def regenerate_keys( self, - resource_group_name, # type: str - namespace_name, # type: str - authorization_rule_name, # type: str - parameters, # type: "_models.RegenerateAccessKeyParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessKeys" + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: "_models.RegenerateAccessKeyParameters", + **kwargs: Any + ) -> "_models.AccessKeys": """Regenerates the primary or secondary connection strings for the namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -1125,7 +1759,8 @@ def regenerate_keys( :param authorization_rule_name: The authorization rule name. :type authorization_rule_name: str :param parameters: Parameters supplied to regenerate the authorization rule. - :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.RegenerateAccessKeyParameters + :type parameters: + ~azure.mgmt.servicebus.v2021_06_01_preview.models.RegenerateAccessKeyParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessKeys, or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys @@ -1136,39 +1771,35 @@ def regenerate_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -1177,14 +1808,16 @@ def regenerate_keys( return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys'} # type: ignore + regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + + + @distributed_trace def check_name_availability( self, - parameters, # type: "_models.CheckNameAvailability" - **kwargs # type: Any - ): - # type: (...) -> "_models.CheckNameAvailabilityResult" + parameters: "_models.CheckNameAvailability", + **kwargs: Any + ) -> "_models.CheckNameAvailabilityResult": """Check the give namespace name availability. :param parameters: Parameters to check availability of the given namespace name. @@ -1199,36 +1832,32 @@ def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CheckNameAvailability') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'CheckNameAvailability') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) @@ -1237,4 +1866,6 @@ def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability'} # type: ignore + + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_operations.py index 890674c90ab3..b3e650481286 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,50 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.ServiceBus/operations") + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,47 +73,49 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationListResult"] + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: """Lists all of the available ServiceBus REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.OperationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -94,17 +124,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.ServiceBus/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.ServiceBus/operations"} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_private_endpoint_connections_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_private_endpoint_connections_operations.py index 4b45a13c96ee..f39028f852b7 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_private_endpoint_connections_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_private_endpoint_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,25 +6,185 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + private_endpoint_connection_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class PrivateEndpointConnectionsOperations(object): """PrivateEndpointConnectionsOperations operations. @@ -47,13 +208,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PrivateEndpointConnectionListResult"] + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnectionListResult"]: """Gets the available PrivateEndpointConnections within a namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -61,45 +222,48 @@ def list( :param namespace_name: The namespace name. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateEndpointConnectionListResult] + :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PrivateEndpointConnectionListResult', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -108,30 +272,35 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections"} # type: ignore + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - namespace_name, # type: str - private_endpoint_connection_name, # type: str - parameters, # type: "_models.PrivateEndpointConnection" - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateEndpointConnection" + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: "_models.PrivateEndpointConnection", + **kwargs: Any + ) -> "_models.PrivateEndpointConnection": """Creates or updates PrivateEndpointConnections of service namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -153,39 +322,35 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PrivateEndpointConnection') - 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) + + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + namespace_name=namespace_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -198,64 +363,62 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - def _delete_initial( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + + def _delete_initial( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - def begin_delete( + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes an existing Private Endpoint Connection. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -266,14 +429,17 @@ def begin_delete( :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( @@ -286,25 +452,18 @@ def begin_delete( resource_group_name=resource_group_name, namespace_name=namespace_name, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -314,18 +473,18 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - namespace_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateEndpointConnection" + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> "_models.PrivateEndpointConnection": """Gets a description for the specified Private Endpoint Connection. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -344,34 +503,31 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) @@ -380,4 +536,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_private_link_resources_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_private_link_resources_operations.py index 012c26ddc0e9..97c3cc9a7a24 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_private_link_resources_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_private_link_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,59 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class PrivateLinkResourcesOperations(object): """PrivateLinkResourcesOperations operations. @@ -44,13 +82,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateLinkResourcesListResult" + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> "_models.PrivateLinkResourcesListResult": """Gets lists of resources that supports Privatelinks. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -67,33 +105,30 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PrivateLinkResourcesListResult', pipeline_response) @@ -102,4 +137,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_queues_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_queues_operations.py index f1718c0c6152..a7aaa309c53d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_queues_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_queues_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,444 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_authorization_rules_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_keys_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_regenerate_keys_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_namespace_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + *, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if skip is not None: + _query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + if top is not None: + _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + namespace_name: str, + queue_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class QueuesOperations(object): """QueuesOperations operations. @@ -45,14 +467,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_authorization_rules( self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SBAuthorizationRuleListResult"] + resource_group_name: str, + namespace_name: str, + queue_name: str, + **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRuleListResult"]: """Gets all authorization rules for a queue. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -62,46 +484,50 @@ def list_authorization_rules( :param queue_name: The queue name. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRuleListResult] + :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SBAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,31 +536,36 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules"} # type: ignore + @distributed_trace def create_or_update_authorization_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - authorization_rule_name, # type: str - parameters, # type: "_models.SBAuthorizationRule" - **kwargs # type: Any - ): - # type: (...) -> "_models.SBAuthorizationRule" + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: "_models.SBAuthorizationRule", + **kwargs: Any + ) -> "_models.SBAuthorizationRule": """Creates an authorization rule for a queue. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -157,40 +588,36 @@ def create_or_update_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBAuthorizationRule') - 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) + + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBAuthorizationRule') + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -199,17 +626,19 @@ def create_or_update_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}'} # type: ignore - def delete_authorization_rule( + create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace + def delete_authorization_rule( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> None: """Deletes a queue authorization rule. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -230,51 +659,49 @@ def delete_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}'} # type: ignore + delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + @distributed_trace def get_authorization_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SBAuthorizationRule" + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.SBAuthorizationRule": """Gets an authorization rule for a queue by rule name. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -295,35 +722,32 @@ def get_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -332,17 +756,19 @@ def get_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}'} # type: ignore + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace def list_keys( self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessKeys" + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.AccessKeys": """Primary and secondary connection strings to the queue. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -363,35 +789,32 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -400,18 +823,20 @@ def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore + + + @distributed_trace def regenerate_keys( self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - authorization_rule_name, # type: str - parameters, # type: "_models.RegenerateAccessKeyParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessKeys" + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: "_models.RegenerateAccessKeyParameters", + **kwargs: Any + ) -> "_models.AccessKeys": """Regenerates the primary or secondary connection strings to the queue. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -423,7 +848,8 @@ def regenerate_keys( :param authorization_rule_name: The authorization rule name. :type authorization_rule_name: str :param parameters: Parameters supplied to regenerate the authorization rule. - :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.RegenerateAccessKeyParameters + :type parameters: + ~azure.mgmt.servicebus.v2021_06_01_preview.models.RegenerateAccessKeyParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessKeys, or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys @@ -434,40 +860,36 @@ def regenerate_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -476,17 +898,19 @@ def regenerate_keys( return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys'} # type: ignore + regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + + + @distributed_trace def list_by_namespace( self, - resource_group_name, # type: str - namespace_name, # type: str - skip=None, # type: Optional[int] - top=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SBQueueListResult"] + resource_group_name: str, + namespace_name: str, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.SBQueueListResult"]: """Gets the queues within a namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -495,54 +919,57 @@ def list_by_namespace( :type namespace_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. + parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip: int :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SBQueueListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBQueueListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBQueueListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBQueueListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_namespace.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', maximum=1000, minimum=0) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=self.list_by_namespace.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SBQueueListResult', pipeline_response) + deserialized = self._deserialize("SBQueueListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -551,30 +978,35 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_namespace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues'} # type: ignore + list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues"} # type: ignore + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - parameters, # type: "_models.SBQueue" - **kwargs # type: Any - ): - # type: (...) -> "_models.SBQueue" + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: "_models.SBQueue", + **kwargs: Any + ) -> "_models.SBQueue": """Creates or updates a Service Bus queue. This operation is idempotent. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -595,39 +1027,35 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBQueue') - 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) + + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBQueue') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBQueue', pipeline_response) @@ -636,16 +1064,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}'} # type: ignore - def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + queue_name: str, + **kwargs: Any + ) -> None: """Deletes a queue from the specified namespace in a resource group. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -664,49 +1094,47 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - namespace_name, # type: str - queue_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SBQueue" + resource_group_name: str, + namespace_name: str, + queue_name: str, + **kwargs: Any + ) -> "_models.SBQueue": """Returns a description for the specified queue. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -725,34 +1153,31 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'queueName': self._serialize.url("queue_name", queue_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBQueue', pipeline_response) @@ -761,4 +1186,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_rules_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_rules_operations.py index cd46a8b1ec15..0655c0708ccf 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_rules_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_rules_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,206 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_subscriptions_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + subscription_id: str, + *, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if skip is not None: + _query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + if top is not None: + _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class RulesOperations(object): """RulesOperations operations. @@ -45,17 +229,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_subscriptions( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - subscription_name, # type: str - skip=None, # type: Optional[int] - top=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RuleListResult"] + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.RuleListResult"]: """List all the rules within given topic-subscription. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -68,56 +252,61 @@ def list_by_subscriptions( :type subscription_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. + parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip: int :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.RuleListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.RuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscriptions.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', maximum=1000, minimum=0) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscriptions_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=self.list_by_subscriptions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscriptions_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RuleListResult', pipeline_response) + deserialized = self._deserialize("RuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -126,32 +315,37 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_subscriptions.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules'} # type: ignore + list_by_subscriptions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules"} # type: ignore + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - subscription_name, # type: str - rule_name, # type: str - parameters, # type: "_models.Rule" - **kwargs # type: Any - ): - # type: (...) -> "_models.Rule" + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: "_models.Rule", + **kwargs: Any + ) -> "_models.Rule": """Creates a new rule and updates an existing rule. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -176,41 +370,37 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Rule') - 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) + + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Rule') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Rule', pipeline_response) @@ -219,18 +409,20 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}'} # type: ignore - def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - subscription_name, # type: str - rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + **kwargs: Any + ) -> None: """Deletes an existing rule. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -253,53 +445,51 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - subscription_name, # type: str - rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Rule" + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + **kwargs: Any + ) -> "_models.Rule": """Retrieves the description for the specified rule. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -322,36 +512,33 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Rule', pipeline_response) @@ -360,4 +547,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_subscriptions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_subscriptions_operations.py index d42b9e5567a6..ec9fb9e960fd 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_subscriptions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_subscriptions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,198 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_topic_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_id: str, + *, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if skip is not None: + _query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + if top is not None: + _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionName": _SERIALIZER.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class SubscriptionsOperations(object): """SubscriptionsOperations operations. @@ -45,16 +221,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_topic( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - skip=None, # type: Optional[int] - top=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SBSubscriptionListResult"] + resource_group_name: str, + namespace_name: str, + topic_name: str, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.SBSubscriptionListResult"]: """List all the subscriptions under a specified topic. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -65,55 +241,60 @@ def list_by_topic( :type topic_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. + parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip: int :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBSubscriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSubscriptionListResult] + :return: An iterator like instance of either SBSubscriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSubscriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBSubscriptionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_topic.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', maximum=1000, minimum=0) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_topic_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=self.list_by_topic.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_topic_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SBSubscriptionListResult', pipeline_response) + deserialized = self._deserialize("SBSubscriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -122,31 +303,36 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_topic.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions'} # type: ignore + list_by_topic.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions"} # type: ignore + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - subscription_name, # type: str - parameters, # type: "_models.SBSubscription" - **kwargs # type: Any - ): - # type: (...) -> "_models.SBSubscription" + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: "_models.SBSubscription", + **kwargs: Any + ) -> "_models.SBSubscription": """Creates a topic subscription. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -169,40 +355,36 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBSubscription') - 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) + + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBSubscription') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBSubscription', pipeline_response) @@ -211,17 +393,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}'} # type: ignore - def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - subscription_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + **kwargs: Any + ) -> None: """Deletes a subscription from the specified topic. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -242,51 +426,49 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - subscription_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SBSubscription" + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + **kwargs: Any + ) -> "_models.SBSubscription": """Returns a subscription description for the specified topic. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -307,35 +489,32 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionName': self._serialize.url("subscription_name", subscription_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_name=subscription_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBSubscription', pipeline_response) @@ -344,4 +523,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}"} # type: ignore + diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_topics_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_topics_operations.py index 157bdcfd54d9..2096591fa1e3 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_topics_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_topics_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,444 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_authorization_rules_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_delete_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_keys_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_regenerate_keys_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_namespace_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + *, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if skip is not None: + _query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + if top is not None: + _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "topicName": _SERIALIZER.url("topic_name", topic_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class TopicsOperations(object): """TopicsOperations operations. @@ -45,14 +467,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_authorization_rules( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SBAuthorizationRuleListResult"] + resource_group_name: str, + namespace_name: str, + topic_name: str, + **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRuleListResult"]: """Gets authorization rules for a topic. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -62,46 +484,50 @@ def list_authorization_rules( :param topic_name: The topic name. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRuleListResult] + :return: An iterator like instance of either SBAuthorizationRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBAuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SBAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SBAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,31 +536,36 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules"} # type: ignore + @distributed_trace def create_or_update_authorization_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - authorization_rule_name, # type: str - parameters, # type: "_models.SBAuthorizationRule" - **kwargs # type: Any - ): - # type: (...) -> "_models.SBAuthorizationRule" + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: "_models.SBAuthorizationRule", + **kwargs: Any + ) -> "_models.SBAuthorizationRule": """Creates an authorization rule for the specified topic. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -157,40 +588,36 @@ def create_or_update_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBAuthorizationRule') - 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) + + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBAuthorizationRule') + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -199,17 +626,19 @@ def create_or_update_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}'} # type: ignore + create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace def get_authorization_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SBAuthorizationRule" + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.SBAuthorizationRule": """Returns the specified authorization rule. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -230,35 +659,32 @@ def get_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) @@ -267,17 +693,19 @@ def get_authorization_rule( return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}'} # type: ignore - def delete_authorization_rule( + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace + def delete_authorization_rule( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> None: """Deletes a topic authorization rule. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -298,51 +726,49 @@ def delete_authorization_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}'} # type: ignore + delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + @distributed_trace def list_keys( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessKeys" + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.AccessKeys": """Gets the primary and secondary connection strings for the topic. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -363,35 +789,32 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -400,18 +823,20 @@ def list_keys( return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore + + + @distributed_trace def regenerate_keys( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - authorization_rule_name, # type: str - parameters, # type: "_models.RegenerateAccessKeyParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessKeys" + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: "_models.RegenerateAccessKeyParameters", + **kwargs: Any + ) -> "_models.AccessKeys": """Regenerates primary or secondary connection strings for the topic. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -423,7 +848,8 @@ def regenerate_keys( :param authorization_rule_name: The authorization rule name. :type authorization_rule_name: str :param parameters: Parameters supplied to regenerate the authorization rule. - :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.RegenerateAccessKeyParameters + :type parameters: + ~azure.mgmt.servicebus.v2021_06_01_preview.models.RegenerateAccessKeyParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessKeys, or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys @@ -434,40 +860,36 @@ def regenerate_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', max_length=50, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessKeys', pipeline_response) @@ -476,17 +898,19 @@ def regenerate_keys( return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys'} # type: ignore + regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + + + @distributed_trace def list_by_namespace( self, - resource_group_name, # type: str - namespace_name, # type: str - skip=None, # type: Optional[int] - top=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SBTopicListResult"] + resource_group_name: str, + namespace_name: str, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.SBTopicListResult"]: """Gets all the topics in a namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -495,54 +919,57 @@ def list_by_namespace( :type namespace_name: str :param skip: Skip is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skip - parameter that specifies a starting point to use for subsequent calls. + parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skip: int :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SBTopicListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBTopicListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBTopicListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.SBTopicListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_namespace.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', maximum=1000, minimum=0) - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=self.list_by_namespace.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_namespace_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + skip=skip, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SBTopicListResult', pipeline_response) + deserialized = self._deserialize("SBTopicListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -551,30 +978,35 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_namespace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics'} # type: ignore + list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics"} # type: ignore + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - parameters, # type: "_models.SBTopic" - **kwargs # type: Any - ): - # type: (...) -> "_models.SBTopic" + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: "_models.SBTopic", + **kwargs: Any + ) -> "_models.SBTopic": """Creates a topic in the specified namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -595,39 +1027,35 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SBTopic') - 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) + + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SBTopic') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBTopic', pipeline_response) @@ -636,16 +1064,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}'} # type: ignore - def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + topic_name: str, + **kwargs: Any + ) -> None: """Deletes a topic from the specified namespace and resource group. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -664,49 +1094,47 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - namespace_name, # type: str - topic_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SBTopic" + resource_group_name: str, + namespace_name: str, + topic_name: str, + **kwargs: Any + ) -> "_models.SBTopic": """Returns a description for the specified topic. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -725,34 +1153,31 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'topicName': self._serialize.url("topic_name", topic_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + topic_name=topic_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SBTopic', pipeline_response) @@ -761,4 +1186,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore +